calculating and plotting 95% confidence intervals

44 views (last 30 days)
In the attached figure I plot the daily mean hot temperature. Instead of plotting the standard deviation around the mean, I would like to plot 95% confidence intervals around the mean.
I have attached my current code to make this figure.
Thanks in advance!
run average_temp_question
filename = 'temp_treatment_data'
temptreatmentdata = 2247×3 table
DT HOT COLD ____________________ ______ ______ 22-Apr-2022 14:13:36 24.345 25.03 22-Apr-2022 14:28:36 27.24 27.26 22-Apr-2022 14:43:36 27.24 27.2 22-Apr-2022 14:58:36 26.94 26.875 22-Apr-2022 15:13:36 26.855 27.005 22-Apr-2022 15:28:36 26.915 27.065 22-Apr-2022 15:43:36 26.875 27.005 22-Apr-2022 15:58:36 26.83 27.005 22-Apr-2022 16:13:36 26.66 26.785 22-Apr-2022 16:28:36 26.765 26.895 22-Apr-2022 16:43:36 26.725 26.835 22-Apr-2022 16:58:36 26.68 26.79 22-Apr-2022 17:13:36 26.785 26.875 22-Apr-2022 17:28:36 26.745 26.875 22-Apr-2022 17:43:36 26.745 26.895 22-Apr-2022 17:58:36 26.765 26.895
Unable to resolve the name 'DHW.datetime'.

Error in average_temp_question (line 49)
plot(DHW.datetime, DHW.DHWhot,'LineWidth',1.5, 'LineStyle','-','Color','k')

Error in run (line 99)
evalin('caller', strcat(script, ';'));

Accepted Answer

Rik
Rik on 28 Sep 2023
A 95% confidence interval means 2 standard deviations on either side. So you simply need to insert *2 in your code.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!