Extracting elements from one matrix according to criteria from another matrix
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
the cyclist
2014-6-28
编辑:the cyclist
2014-6-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!