shade area under curve - CDF plot

Hi, I'm looking to shade/fill the area under the curve on a cdf plot. This is fairly simple when plotting x,y data using the area or fill function. However, I cant find a way to do it when plotting a cdf as you only use one column of data to construct the plot. Any help would be much appreciated.
Best regards, Ciara

 採用された回答

Star Strider
Star Strider 2017 年 8 月 21 日

0 投票

I don’t understand what the problem is.
Try this:
mu = 1;
sd = 2;
x = linspace(mu-10*sd, 1.96);
CDF = normcdf(x, mu, sd);
figure(1)
area(x, CDF)

4 件のコメント

C Ryan
C Ryan 2017 年 8 月 21 日
Hi Star Strider, thanks for your reply.I have attached my code below.What I'm not clear on is how to apply the area function when you only have one column of data as I do. Generally, you would have a set of x values and a corresponding set of y values, no? e.g. X = [1,7,3,4]; Y = [6,8,3,5]; area(X,Y) but in my case I am only taking data from one column "data=num(:,1);" in my xl file. I hope that helps to explain what I'm asking!
[num,txt,raw]=xlsread('test.xlsx');
data=num(:,1);
h = cdfplot(data); h.LineWidth = h.LineWidth + 1;
xlabel('Errors per sheet %','fontsize', 18)
ylabel('Proportion of values less than or equal to x','fontsize', 18)
title('(a) CDF - Evaluation of student errors n=2556', 'fontsize', 20)
set(gca,'fontsize',18)
Star Strider
Star Strider 2017 年 8 月 21 日
The cdfplot function creates the necessary vectors for you:
data = 1 + 2*randn(1, 25); % Create Data
figure(1)
h = cdfplot(data);
hold on
area(h.XData, h.YData)
hold off
C Ryan
C Ryan 2017 年 8 月 21 日
Thank you. This is what I've been trying to do.
Star Strider
Star Strider 2017 年 8 月 21 日
As always, my pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2017 年 8 月 21 日

コメント済み:

2017 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by