Quantile function - different values in different versions of Matlab
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuesta aceptada
Wayne King
el 20 de Feb. de 2013
I get the answer 5.4 in both R2011b and in R2012b. I'm not sure why you are getting 5 in R2011b. Perhaps you are using a non-MathWorks' version of quantile in R2011b?
If you enter
>> which quantile
do you get some path back like:
matlab\toolbox\stats\stats\quantile.m
In your case you can always use:
a=[1:98];
round(quantile(a,0.05))
1 comentario
Más respuestas (2)
Youssef Khmou
el 20 de Feb. de 2013
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 .
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!