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

1 次查看(过去 30 天)
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)

采纳的回答

Rik
Rik 2018-6-11
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by