how to convert 1D element into 2D element in a matirx?

1 次查看(过去 30 天)
hi, i need to find the location of elements in a matrix as (row,column) value. what function is used to get the row and column of a element?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-10-17
编辑:Azzi Abdelmalek 2013-10-17
Use find function
doc find
Example
A=[1 2 3;4 5 6;7 8 9]
[ii,jj]=find(A)

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2013-10-17
A = [4 0 3 0
4 4 4 -3
-3 -3 2 -3
5 0 -1 5]
s = size(A);
[irow,icol] = ndgrid(1:s(1),1:s(2));
out = [irow(:),icol(:),A(:)];
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-10-18
Can you explain, for example, why, for locatn(1,5) , it should be 17 and not 3

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by