Help with MATLAB Graphing Error Bars for 1D Arrays

  • Context: MATLAB 
  • Thread starter Thread starter smileandbehappy
  • Start date Start date
  • Tags Tags
    Graphing Matlab
Click For Summary
SUMMARY

The discussion focuses on resolving an error encountered in MATLAB while attempting to plot error bars for two 1D arrays. The user attempted to use a constant error value defined as 'e' with the syntax '(+-0.05)', which is incorrect. The solution provided clarifies that 'e' must be a vector matching the length of the arrays 'W' and 'V1', and suggests using a symmetric error representation by defining 'e' as a vector of the appropriate length.

PREREQUISITES
  • Familiarity with MATLAB syntax and functions
  • Understanding of 1D arrays in MATLAB
  • Knowledge of error bar plotting techniques
  • Basic grasp of vector operations in MATLAB
NEXT STEPS
  • Learn how to create vectors in MATLAB using the 'linspace' or 'colon' operator
  • Explore the 'errorbar' function in MATLAB documentation for advanced usage
  • Investigate how to customize error bars for different data sets
  • Study MATLAB's plotting functions to enhance data visualization skills
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and researchers who need to visualize data with error bars, particularly those working with 1D arrays and seeking to troubleshoot common plotting issues.

smileandbehappy
Messages
66
Reaction score
0
Im trying to plot a graph with eror bars for two 1d arrays. But for some reason MATLAB won't let me do it. Can you please help me as quickly as possible as I am currectly sitting in a computer lab and am very tired.

My code is:

W = 10:10:60;
V1 = [0.103,0.223,0.351,0.436,0.555,0.664];
e = (+-0.05);
errorbar(W,V1,e)

thanks
 
Physics news on Phys.org
your problem is with variable 'e', it must be a vector of same length as W and V1. It is okay to specify constants in a vector, but +- is not a valid prefix. Leaving off the +-, the plot will give a symmetric error-bar 2e long.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
3
Views
2K