Sort(x) doesn't work properly.
5 views (last 30 days)
Show older comments
Julian Wzorek
on 12 Nov 2020
Commented: Walter Roberson
on 12 Nov 2020
Why when I'm trying to sort , at the end there are numbers that are not sorted?
0 Comments
Accepted Answer
Ameer Hamza
on 12 Nov 2020
Edited: Ameer Hamza
on 12 Nov 2020
How do you know it is not sorted. The following code shows that it is indeed sorted
daily_logreturns_sorted = sort(daily_logreturns);
tf = all(diff(daily_logreturns_sorted)>=0)
Result
>> tf
tf =
logical
1
2 Comments
Walter Roberson
on 12 Nov 2020
Or a slightly easier test,
daily_logreturns_sorted = sort(daily_logreturns);
issorted(daily_logreturns_sorted)
More Answers (0)
See Also
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!