plot cdf and calculate 90th percentile value

25 次查看(过去 30 天)
hello all ,
i have a variable z_cdf attached;
prctile(z_cdf,90) % answer is 30.9361
now using z_cdf i am trying to plot cdf.
[f,x] = ecdf(z_cdf);
plot(x,f,'HandleVisibility','off','color',[1 0 0],'LineWidth',2);
now in the plot i need to show the line representing the 90th percentile value as shown in the below figure. i.e. the line corresponding to cdf / y-axis= 0.9;
please help me with the line plotting option and also
according to plot x-axis value corresponding to y-axis value 0.9 is 30.7553. why is this x value not equal to prctile(z_cdf,90).
help me with similar cdf plot options where prctile(z_cdf,90) matches (prctile(z_cdf,90),0.9) in plot.

回答(1 个)

Star Strider
Star Strider 2020-10-23
To plot the dashed lines at the appropriate percentiles:
pctl = [50 90];
pctlv = prctile(z_cdf,[50 90]); % answer is 30.9361
[f,x] = ecdf(z_cdf);
figure
plot(x,f,'color',[1 0 0],'LineWidth',2)
hold on
for k = 1:numel(pctl)
plot([1;1]*pctlv(k), [0;1]*pctl(k)/100, '--k')
plot([0;1]*pctlv(k), [1;1]*pctl(k)/100, '--k')
end
hold off
producing:
.

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by