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

1 Ansicht (letzte 30 Tage)
sheno39
sheno39 am 17 Okt. 2013
Kommentiert: Andrei Bobrov am 18 Okt. 2013
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?
  2 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 17 Okt. 2013
Your title does not match the content of your question
sheno39
sheno39 am 17 Okt. 2013
sir, i need to find the row,column value for each element in a matrix

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 17 Okt. 2013
Bearbeitet: Azzi Abdelmalek am 17 Okt. 2013
Use find function
doc find
Example
A=[1 2 3;4 5 6;7 8 9]
[ii,jj]=find(A)

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 17 Okt. 2013
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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 18 Okt. 2013
Can you explain, for example, why, for locatn(1,5) , it should be 17 and not 3

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by