Ind2Sub在Matlab中使用矩阵索引

时间:2014-05-27 11:18:16

标签: matlab matrix

enter image description here [rowss colum] = ind2sub(size(matri_working_now),sub2ind(size(matrix_working_now),458,6));手动给出了458和6个值。

我希望从另一个矩阵中读出这些值。我该怎么办?我试图遍历矩阵并使用索引,但它没有工作。 matrix_stables是我需要使用的具有值的矩阵。

[nrows,ncols] = size(matrix_stables);
%for row = 1:nrows
%[column] = ind2sub(size(matri_working_now),sub2ind(size(matrix_working_now),matrix_stables((row),2)));

谢谢!

1 个答案:

答案 0 :(得分:2)

你可以简单地做

[rowss colum] = ind2sub( size(matri_working_now),...
                         matrix_stables(:,1), matrix_stables(:,2) );