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