MATLAB: Sorting a time series

MATLABsort

Hello,
II have a time series Yt and I sorted them in ascending order and I got Yi, then I used them in a function and I got Zi as Zi=F(Yi), How can I rearrange Zi to Zt (the same order of Yt)?

Best Answer

You need to use the optional output from the sort function that contains the sort order.
[Y, idx] = sort(time_series);
Zt = Zi(idx);