Sorting of trigonometric functions
Ältere Kommentare anzeigen
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 Kommentare
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
am 9 Jan. 2023
Bearbeitet: Albert Zurita
am 9 Jan. 2023
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



