Sorting of trigonometric functions
Show older comments
I am trying to sort the outputs from sine or cosine function as below. I have a set of angles, for which I compute the sine and then I sort the result of the sine. Is there a way in which I could avoid sorting the sine output and apply a function to the original sorted angle indexes? I presume this is a very stupid question and the answer is NO, but I thought whether there could be a combination in which I could apply a function to ixs1 to get ixs2, so ixs2 = f(ixs1);
ang = rand(1,100)*2*pi;
[~,ixs1] = sort(ang);
[~,ixs2] = sort(sin(ang));
plot(ixs1,'.');hold on;
plot(ixs2);
2 Comments
as you expected , the answer is NO because sin is not a monotonic function on 0 - 2pi range
if you had a monotonic function, both indexes would be in linear relationship
ang = rand(1,100)*2*pi;
[~,ixs1] = sort(ang);
% [~,ixs2] = sort(sin(ang)); % answer = NO
[~,ixs2] = sort(1+3*(ang)+0.3*(ang).^2); % answer = YES
plot(ixs1,ixs2,'*');
Albert Zurita
on 9 Jan 2023
Edited: Albert Zurita
on 9 Jan 2023
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


