Quantile function - different values in different versions of Matlab
Show older comments
Hello!
I have a complicated code, which worked perfectly in Matlab R2011b, but gives me wrong numbers in Matlab R2012b. I found out that the reason is that the quantile function gives different outputs in these two different versions of Matlab. I will not show you my code, since it is long and the problem can be illustrated by the following very simple example:
a=[1:98];
quantile(a,0.05)'
Output, Matlab R2011b: 5
Output, Matlab R2012b: 5.40
My problem is that I would like to use the newer version (R2012b) and get the result 5. The reason is that in the later step, I will have to use the find function:
index=find(a==quantile(a,0.05))
which obviously gives me an empty matrix, because the number 5.40 is not there. However, in the old version (R2011b), it would give an index, because number 5 is in the vector.
So, the question is: "How can I get the new version of Matlab to pick the element FROM the vector that is closest to the 5% quantile"
Thank you very much for your time and consideration!
Accepted Answer
More Answers (2)
Youssef Khmou
on 20 Feb 2013
0 votes
hi, You can resolve this problem by simply opening the function "quantile" in Mat2011b copy it and past it in your directory "Root_Mat\toolbox\stats\quantile011.m" name it "quantile011.m" to keep both versions .
Aleksandrs
on 22 Feb 2013
Categories
Find more on Logical 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!