http://www.mathworks.com/matlabcentral/newsreader/view_thread/243402
MATLAB Central Newsreader  Unsort values
Feed for thread: Unsort values
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Fri, 30 Jan 2009 01:18:01 +0000
Unsort values
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243402#624902
Patrick Wang
Hi<br>
<br>
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.<br>
The following is my code:<br>
<br>
RPSDBsort = sort(reversed_Power,'descend');<br>
RPSDBsort(1:5) = [];<br>
[y x] = max(RPSDBsort);<br>
display(RPSDBsort);<br>
display(x);<br>
display(y);<br>
<br>
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?<br>
<br>
Thank you so much.<br>
<br>
Patrick

Fri, 30 Jan 2009 02:24:01 +0000
Re: Unsort values
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243402#624908
Roger Stafford
"Patrick Wang" <chris00558800@hotmail.com> wrote in message <gltkg9$je4$1@fred.mathworks.com>...<br>
> Hi<br>
> <br>
> 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.<br>
> The following is my code:<br>
> <br>
> RPSDBsort = sort(reversed_Power,'descend');<br>
> RPSDBsort(1:5) = [];<br>
> [y x] = max(RPSDBsort);<br>
> display(RPSDBsort);<br>
> display(x);<br>
> display(y);<br>
> <br>
> 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?<br>
> <br>
> Thank you so much.<br>
> <br>
> Patrick<br>
<br>
You need the second argument returned by 'sort'.<br>
<br>
[RPSDBsort,p] = sort(reversed_Power,'descend');<br>
reversed_Power(p(1:5)) = [];<br>
<br>
Roger Stafford

Fri, 30 Jan 2009 03:15:05 +0000
Re: Unsort values
http://www.mathworks.com/matlabcentral/newsreader/view_thread/243402#624912
Matt Fig
In addition to what Roger said, there is no reason to call max. The first value is the largerst because you sorted the vector.<br>
<br>
reversed_Power = randperm(20); % Data for example.<br>
RPSDBsort = sort(reversed_Power,'descend');<br>
RPSDBsort(1:5) = [];<br>
y = RPSDBsort(1);<br>
x = 1;<br>
% [y x] = max(RPSDBsort);<br>
display(RPSDBsort);<br>
display(x);<br>
display(y);<br>
<br>
<br>
<br>
<br>
Ue\KGU[&eeQleKeeHl?_KZTHVRNURZGKS3sGeGZOOUN+GSMVUGIGU [eINT