Filter löschen
Filter löschen

find the index of non-zero elements of three dimensional matrix and rank the them according to the value

1 Ansicht (letzte 30 Tage)
For a three dimentional matrix: A=randi(10,[10 10 5]), I want to find the index (x,y,z) of each non-zero element of A and then rank the all the non-zero elements according to the value.
However, when running the following code, it seems 'find' can only have three outputs. May I know how to achive this?
A=randi(10,[10 10 5]);
[x,y,z,val]=find(A);
sortrows([val,x,y,z],1)

Akzeptierte Antwort

Rik
Rik am 11 Jun. 2018
You can use my FEX submission findND.
A=randi(10,[10 10 5]);
[x,y,z,val]=findND(A);
sortrows([val,x,y,z],1)

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by