shaded confidence interval plotting with shade area (patch)

15 次查看(过去 30 天)
Hello,
I'm trying to plot the shadow area between the confidence interval with the line in the middle. I've tried a few approaches, but each time I'm getting the same results (plot image). I've attached a data and code below. Please help, I don't know why I have this problem. I've read similar tags, and tried to adhere to the solutions, but it seems that doesn't work for my case.
% Using Matlab - calculations of confidence interval
pd = fitdist(X,'Normal')
ci = paramci(pd)
a4=ci(1,1)/pd.mu;
b4=ci(2,1)/pd.mu;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=X.*a4;
y=X.*b4;
Ymax=y;
Ymin=x;
figure
plot(time,Ymax)
hold on
plot(time,Ymin)
line([time(end) time(end)],[Ymin(end),Ymax(end)])
line([time(2) time(2)],[Ymin(1),Ymax(1)])
patch([time fliplr(time)], [Ymax fliplr(Ymin)], 'g')

采纳的回答

Star Strider
Star Strider 2021-4-7
The data in ‘data-confidence interval.xls’ are read in as column vectors, so fliplr simply flips a column vector, and accomplishes nothing. It is necessary to vertically concatenate the vectors with their flipped versons.
Try this instead:
patch([time; flipud(time)], [Ymax; flipud(Ymin)], 'g')
producing:
.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by