faqts : Computers : Programming : Languages : Matlab : Handling Graphics

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 4 people (50%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

How do I plot only every X bar in an errorbar graph?

Jun 17th, 2001 02:26
Per M Knutsen,


Simply make a new vector which is a "duplicate" of the error vector, 
zero out the elements that you don't want error bars for, and use that 
as the "new" error vector.
For example, the following creates a really messy graph (adapted from 
the help for ERRORBAR):
% Set up all of the data...
x = 1:.1:10;
y = sin(x);
e = std(y)*ones(size(x));
% Plot it.  The graph is kind of messy.
errorbar(x,y,e);
To make a less messy graph, create a new error vector, zero out most of 
its elements, and display that instead.
% Make a copy of e with only every fifth element nonzero.
e2 = e;
for i = 1:length(e2), if rem(i, 5), e2(i) = 0; end; end
% Plot using that one instead.
errorbar(x,y,e2)