find row and column of a value in cell array
Show older comments
I have A matrix of dimension 10*10. C is linear index of non zero element in A
C = {[11],[33;44;54;55],[77;87;98]};
I want to find row and column of linear index in cell array.
result should be
row_col = {[1,2],[3,4; 4,5; 4,6; 5,6],[7,8;7,9;8,10]}
Accepted Answer
More Answers (1)
David Hill
on 11 Apr 2020
Your example does not get the correct result.
Size_A =[10 10];
row_col = cell([],1);
for i=1:length(C)
[rows,cols] = ind2sub(Size_A,C{i}(:));
row_col{i} = [rows,cols];
end
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!