MATLAB Answers

0

Keep proper Indexing after sorting

Asked by M@lik Ali on 5 Feb 2013
Latest activity Edited by Stephen Cobeldick on 21 Jan 2017

I have a matrix like below

 fset(:,:,1) = rand(5,16); 
 fset(:,:,2) = rand(5,16);
 fset(:,:,3) = zeros(5,16);
 sorted_fset = sort(fset,3);

My problem is i have 999 small matrix in a big matrix like this means

 fset(:,:,i),i=1,2,3,4....999

I represent the each image actually, now when i sort the matrix it sort for me but i cannot recognize the index of each image.

Like in above case

 fset(:,:,3) will be fset(:,:,1)

but actually it was 3, so how i can recognize the image index after sorting in this case. if any confusion please comment

  0 Comments

Log in to comment.

Tags

1 Answer

Answer by Jan Simon
on 5 Feb 2013
Edited by Jan Simon
on 5 Feb 2013

[sorted_fset, index] = sort(fset, 3);

Matlab offers an exhaustive documentation which should be read in case of difficulties:

help sort
doc sort

  2 Comments

I tried to read from matlab help

i try this one, but how i can get the corresponding index from this.

I do not understand your comment. I've posted the method to get the sorting indices as 2nd output already. This method is explained in the mentioned help text also. So what are you looking for now?

Log in to comment.


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!