- Standard Deviation: Useful when you want to show the spread of your data.
- Standard Error: Useful for showing how precisely you know the mean of your data.
- Confidence Intervals: Useful for providing a range for parameter estimates.
- Percentiles: Useful for non-parametric data or skewed distributions.
Code and plot error bounds timeseries data
3 ビュー (過去 30 日間)
古いコメントを表示
So I'm plotting average kW per minute for two systems in blue and red, what would be the most concise way to plot the error bars over each line?

I also have a similar plot just calculating and plotting average kW per hour (so there's less noise) for two systems below
Could I just put the error bars for the hourly plot? I saw this post online for error bars and I thought it looked very clean but I had trouble following it since the error bounds are randomly generated and not calculated. https://brendanhasz.github.io/2019/07/03/matlab-uncertainty-viz
Any help would be much appreciated. Thanks!
0 件のコメント
回答 (1 件)
Anudeep Kumar
2025 年 4 月 2 日
Hey Fatemah,
As mentioned in the link provided, “errorbar()” function would be the best bet for your use case. For the error bounds calculation based on your graph, there are multiple methods you can follow:
Since you are plotting average kW values over time and assuming you have multiple measurements for each time point (such as multiple days of data for each minute/hour), using either the Standard Error or Confidence Intervals would be appropriate.
You can calculate these error bounds using MATLAB functions like “mean ”, “std”, and “sqrt”. Here’s how you can do it:
>> % Assuming your data is of the shape num_of_measurements x time
>> meanSystem = mean(your_Data);
>> seSystem = std(your_Data) / sqrt(num_of_measurements);
>> errorbar(time, meanSystem, seSystem, 'b', 'LineWidth', 1.5);
I have attached below the links to documentation for the functions for better adapting the code for your usecase.
“mean()”:
“std()”:
“sqrt()”:
“errorbar() ” :
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!