How can i draw Confidence interval graph for my data?...(i'm beginner)
15 次查看(过去 30 天)
显示 更早的评论
I used this code ...
x = 1:100; % Create Independent Variable
y = randn(50,100); % Create Dependent Variable ‘Experiments’ Data
N = size(y,1); % Number of ‘Experiments’ In Data Set
yMean = mean(y); % Mean Of All Experiments At Each Value Of ‘x’
ySEM = std(y)/sqrt(N); % Compute ‘Standard Error Of The Mean’ Of All Experiments At Each Value Of ‘x’
CI95 = tinv([0.025 0.975], N-1); % Calculate 95% Probability Intervals Of t-Distribution
yCI95 = bsxfun(@times, ySEM, CI95(:)); % Calculate 95% Confidence Intervals Of All Experiments At Each Value Of ‘x’
figure
plot(x, yMean) % Plot Mean Of All Experiments
hold on
plot(x, yCI95+yMean) % Plot 95% Confidence Intervals Of All Experiments
hold off
grid
and then I want to draw graph.. like this..
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/562951/image.png)
so, Someone gave me the code
Replace the second plot call with
patch([x, fliplr(x)], [yCI95(1,:) fliplr(yCI95(2,:))], 'b', 'EdgeColor','none', 'FaceAlpha',0.25)
like this picture...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/562956/image.jpeg)
q1 ) Is this a certain confidence interval graph correct? I think that It is very different from the original data picture
this is original graph![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/562961/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/562961/image.jpeg)
q2 ) and then How do I draw a confidence interval graph using my data? my data is uploaded
plz help me..
0 个评论
回答(1 个)
Bjorn Gustavsson
2021-3-26
The second graph is certainly not correct - since it is centred around zero and not around the average at each point, you have to add that t your confidence intervalls. For neat plots like this there are a number contributions on the file exchange: confplot, errorfill, boundedline, shaded-error-bar-yy, fillplot-mat, errorshade, shadederrorbar, shplot and more.
HTH
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!