Correlation funciton to find eigenvalues
Afficher commentaires plus anciens
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
Réponses (2)
the cyclist
le 2 Août 2013
Modifié(e) : the cyclist
le 2 Août 2013
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.
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 commentaire
Nicole
le 2 Août 2013
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!