next up previous contents
Next: Parametric plots Up: 2.1.3 Other 2-D plots Previous: Histograms   Contents Plots with error bars

Often when we are plotting data we can estimate the error in each point and the magnitude of error may vary from point to point. This is often the case when we plot data generated via Monte Carlo simulations or in experimental data. The errorbar command can indicate the amount of error for each point using vertical error bars. Try this,
% Plotting with error bars
close all; clear all;
x = linspace(0,pi,30); % 30 equally spaced points between 0 and pi
y = 1-x.^2/2+x.^4/(4*3*2); % Approximate the cosine function
error = cos(x)-y; % compute the error
Note that at $\pi$, the function should be $-1$ if the approximation were exact. Note the error is larger for increasing $x$ values and how this is indicated by the size of the error bars.

Gus Hart 2005-01-28