how to convert 1D element into 2D element in a matirx?
Mostra commenti meno recenti
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 Commenti
Azzi Abdelmalek
il 17 Ott 2013
Your title does not match the content of your question
sheno39
il 17 Ott 2013
Risposta accettata
Più risposte (1)
Andrei Bobrov
il 17 Ott 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 Commenti
sheno39
il 18 Ott 2013
Modificato: Azzi Abdelmalek
il 18 Ott 2013
Azzi Abdelmalek
il 18 Ott 2013
Can you explain, for example, why, for locatn(1,5) , it should be 17 and not 3
Andrei Bobrov
il 18 Ott 2013
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!