Reputation: 17
I have over 1 thousand data points on a graph. I would like to plot some error bars every 100 or so points data points.
x = 1:1500:1100;
y = [1:1200];
err = ?
plot(x.y);
hold on;
errorbar(x,y,err);
What value do I need for 'err' so I would only get 10 error bars?
Upvotes: 0
Views: 340
Reputation: 18905
As David pointed out in his comment, your code is no proper MATLAB code. Nevertheless, I presume you have sufficient MATLAB understanding: Basically you need to set up separate x
and y
values for your errorbar
as well as the actual errors err
, which should be plotted. Then, you can use the proper errorbar
command.
Let's have a look at this small example:
x = -5:0.1:5;
y = sin(x);
xErr = linspace(-5, 5, 11); % Specify x locations for errorbar plot
yErr = sin(xErr); % The y values at these x locations
err = rand(1, 11); % The actual errors, here: some random values
plot(x, y, 'r'); % Plot
hold on;
errorbar(xErr, yErr, err, 'o'); % Actual errorbar plot at specific x locations
hold off;
You'll get an output like this:
Disclaimer: I made this with Octave 5.1.0, but the syntax should be identical to MATLAB. If not, please report any errors.
Hope that helps!
Upvotes: 2