Code and plot error bounds timeseries data

3 ビュー (過去 30 日間)
Fatemah Ebrahim
Fatemah Ebrahim 2020 年 6 月 11 日
回答済み: Anudeep Kumar 2025 年 4 月 2 日
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!

回答 (1 件)

Anudeep Kumar
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:
  • 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.
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() ” :

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by