How can i draw Confidence interval graph for my data?...(i'm beginner)

10 views (last 30 days)
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..
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...
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
q2 ) and then How do I draw a confidence interval graph using my data? my data is uploaded
plz help me..

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 26 Mar 2021
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

Categories

Find more on Audio Processing Algorithm Design 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!