我不是Matlab用户,但现在必须处理它。我无法找到如何:
[row,col]=matrix1[matrix1==100];
如何排除row = 5?
答案 0 :(得分:1)
以下程序应说明您需要采取的步骤(即使可能采用更有效的解决方案):
%// Generate some numbers:
matrix1 = randi(4,5);
%// Find the indices of the elements you are looking for:
VALUE_TO_FIND = 3;
[row,col] = find(matrix1==VALUE_TO_FIND);
%// To exclude a certain row, simply "delete" the elements pointing there:
ROW_TO_IGNORE = 4;
col(row==ROW_TO_IGNORE)=[]; %//it is important that this line comes first
row(row==ROW_TO_IGNORE)=[];
如果要忽略某一列,请切换最后两行的顺序(并相应地更改括号中的条件)。
答案 1 :(得分:0)
您可以将其作为后期处理:
sel = row~= 5;
row = row(sel);
col = col(sell);