More sophisticated code than a for loop with i is large
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi there I am trying to calculate a scatter matrix for some data. so basically my Eigen values are in a matrix of the form; [e11 e12 e13; e21 e22 e23; e31 e32 e33; ...... e101 e102e103]
and my scatter matrix is of the form;
[e11^2 + e21^2 + e31^2 + ... e101^2, e11e12 + e21e22 + ... +e101e102, e11e13 + ... e101e103; e11e12 + e21e22 + ... +e101e102, e12+e22+e32+..e102, e12e13+e22e23+...+e102e103; e11e13 + ... e101e103, e12e13+e22e23+...+e102e103; e13^2+e23^2+...+e103^2]
Now in some cases instead of n = 10 as is the case above n =in the thousadns. is there a neat way to code for this?
1 Commento
Jan
il 10 Lug 2013
How is "n=10" related to the posted code. I think, names like e101e103 are such ugly, that it is near to impossible to read the code.
Risposta accettata
Andrei Bobrov
il 10 Lug 2013
Modificato: Andrei Bobrov
il 10 Lug 2013
Let e = [e11 e12 e13; e21 e22 e23; e31 e32 e33; ...... e101 e102e103];
out = e.'*e;
out(2,2) = sum(e(:,2));
0 Commenti
Più risposte (1)
Hugo
il 10 Lug 2013
Please notice that in the "scatter matrix" that you showed as an example there are elements that are repeated, and the structure is not exactly a matrix.
So, it seems that the matrix of eigenvalues, let's say A, is of size n x 3. Is the scatter matrix of this data what you want? You can simply do
A'*A, and it will return a 3x3 matrix where each element Aij has the values:
Aij= sum_n ( eni * enj ), which partially coincides with your example.
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!