Got Questions? Get Answers.
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

Thread Subject:
Unsort values

Subject: Unsort values

From: Patrick Wang

Date: 30 Jan, 2009 01:18:01

Message: 1 of 3

Hi

I was asked to implement an automatically zoom in feature in my lab, and I have figure out that I can sort my values, and delete the top few numbers and then apply max value to find the coordinate of the fifth largest value, and thus I can set my new x window limit. However, I do not know how to place the sorted array back into the original array, and I do not find "unsort" such command.
The following is my code:

RPSDBsort = sort(reversed_Power,'descend');
RPSDBsort(1:5) = [];
[y x] = max(RPSDBsort);
display(RPSDBsort);
display(x);
display(y);

and this would only return me the sorted array of the RPSDBsort, is there anyway that I can delete the biggest five values in the "reversed_Power" array?

Thank you so much.

Patrick

Subject: Unsort values

From: Roger Stafford

Date: 30 Jan, 2009 02:24:01

Message: 2 of 3

"Patrick Wang" <chris00558800@hotmail.com> wrote in message <gltkg9$je4$1@fred.mathworks.com>...
> Hi
>
> I was asked to implement an automatically zoom in feature in my lab, and I have figure out that I can sort my values, and delete the top few numbers and then apply max value to find the coordinate of the fifth largest value, and thus I can set my new x window limit. However, I do not know how to place the sorted array back into the original array, and I do not find "unsort" such command.
> The following is my code:
>
> RPSDBsort = sort(reversed_Power,'descend');
> RPSDBsort(1:5) = [];
> [y x] = max(RPSDBsort);
> display(RPSDBsort);
> display(x);
> display(y);
>
> and this would only return me the sorted array of the RPSDBsort, is there anyway that I can delete the biggest five values in the "reversed_Power" array?
>
> Thank you so much.
>
> Patrick

  You need the second argument returned by 'sort'.

 [RPSDBsort,p] = sort(reversed_Power,'descend');
 reversed_Power(p(1:5)) = [];

Roger Stafford

Subject: Unsort values

From: Matt Fig

Date: 30 Jan, 2009 03:15:05

Message: 3 of 3

In addition to what Roger said, there is no reason to call max. The first value is the largerst because you sorted the vector.

reversed_Power = randperm(20); % Data for example.
RPSDBsort = sort(reversed_Power,'descend');
RPSDBsort(1:5) = [];
y = RPSDBsort(1);
x = 1;
% [y x] = max(RPSDBsort);
display(RPSDBsort);
display(x);
display(y);




Ue\KGU[&eeQleKeeHl?_KZTHVRNURZGKS3sGeGZOOUN+GSMVUGIGU [eINT

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us