Extracting elements from one matrix according to criteria from another matrix

7 vues (au cours des 30 derniers jours)
MiauMiau
MiauMiau le 28 Juin 2014
Commenté : MiauMiau le 28 Juin 2014
I have the following problem: I have say 100 3-dimensional points, and a correlation matrix A with the correlation of all the points to each other, hence A has the dimensions 100 x 100.
For all my points I have another matrix B with the coordinates of each point, such that B is a 3 x 100 matrix.
Now I want the following to be done: From my correlation matrix A, I only want to have the correlation of points extracted, where the x coordinate of the point is 0 or bigger than zero, such that I arrive at a new correlation matrix, and also for the matrix B I only want to keep the points which fullfill this criterion. The x values are stored in the first row of the matrix B for each of the 100 points.
How could I do that?

Réponses (1)

the cyclist
the cyclist le 28 Juin 2014
Modifié(e) : the cyclist le 28 Juin 2014
If I understand correctly what you want, I think this does it.
index = B(1,:)>=0;
A = A(index,:);
A = A(:,index);
B = B(:,index);
  3 commentaires
the cyclist
the cyclist le 28 Juin 2014
Sorry, I thought your B was 100x3. I corrected my code.
MiauMiau
MiauMiau le 28 Juin 2014
Ok, thanks! B is correct now, but A isn't. So for A, since in B only column 1 and 4 are kept, we would need to keep only the correlation between the first point and the fourth. These are encoded in A in (1,1) (correlation of the first point with itself), (4,4) (correlation of the fourth point with itself), then (1,4) and (4,1). How would we do that?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by