Find function - index by rows?
Ältere Kommentare anzeigen
For the find function, I noticed that it indexes downward column by column. Is there a way to make it so that it indexes left to right row by row?
1 Kommentar
Stephen23
am 27 Apr. 2016
Nope. Transpose your data and start thinking in terms of columns, not rows.
Antworten (2)
Azzi Abdelmalek
am 27 Apr. 2016
Apply find function to the transpose of your matrix
find(A'==2) % for example
2 Kommentare
Eric Tran
am 27 Apr. 2016
Azzi Abdelmalek
am 27 Apr. 2016
You are not changing your Matrix, your are just operating on another Matrix which is A'
Andrei Bobrov
am 27 Apr. 2016
Bearbeitet: Andrei Bobrov
am 27 Apr. 2016
Example:
A = rand(15) > .4; % your array
[i0,j0] = find(A);
c = num2cell(sortrows([i0,j0],1),1);
[i_out,j_out] = c{:};
or jast (as by Azzi)
[j_out,i_out] = find(A.');
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!