Correlation funciton to find eigenvalues

Hi I'm trying to do a correlation matrix between 12 matrices in MatLab. I'm using this command:
for j=1:12;
for i=1:12;
for k=1:181;
A(i,j) = A(i,j)+z(k,i)*z(k,j); %which A= matrix elements
end
end
end
but i keep getting this error: Undefined function 'A' for input arguments of type 'double'.
how can I make this work? Thanks

回答(2 个)

In the very first line inside all the for loops, you have A(i,j) on the right-hand side of the equation, before you have defined it. MATLAB doesn't know what to do there.
You perhaps need to initialize A:
A = zeros(12,12);
before this code.
Cedric
Cedric 2013-8-2
编辑:Cedric 2013-8-2
Why not using CORR2? If your 12 matrices were stored in a cell array M, you would do something like
n = numel(M) ;
C = zeros(n) ;
for ii = 2 : n
for jj = 1 : ii-1
C(ii,jj) = corr2(M{ii}, M{jj}) ;
end
end
C = C + C.' + eye(n) ;

1 个评论

Because I have to use this other equation for my coastal profile work. (:

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

提问:

2013-8-2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by