给定一个数字向量,我想,例如,检索所有正系数的坐标vector(i,j)
,以便进一步处理向量。 MATLAB的语法是什么?
示例:对于[-1.143,0.089,2.654,4.142,]'
我想要检索[2,1;3,1;4,1]
答案 0 :(得分:0)
%just some random data
M=rand(10,10)-.666
%get all indices which are positive, using logical indexing
positive_indices=M>0;
%get the positive data:
M(positive_indices)
%get the row and column index of the positive data
[r,c]=find(positive_indices)