Kashif Nawaz
Kashif Nawaz

Reputation: 95

Ind2Sub using matrix indexing in Matlab

enter image description here[rowss colum] = ind2sub(size(matri_working_now),sub2ind(size(matrix_working_now),458,6)); the 458 and 6 values have been manually given.

I would like these values to be read out from another matrix. How would I do that? I tried to iterate through the matrix and use indexing but it didnt work. matrix_stables is the matrix i need to use which has the values.

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

Thanks!

Upvotes: 0

Views: 744

Answers (1)

Shai
Shai

Reputation: 114866

You can simply do

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

Upvotes: 2

Related Questions