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 件)

the cyclist
the cyclist 2013 年 8 月 2 日
編集済み: the cyclist 2013 年 8 月 2 日

0 投票

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 日

0 投票

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 件のコメント

Nicole
Nicole 2013 年 8 月 2 日
Because I have to use this other equation for my coastal profile work. (:

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating 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