Problem with syntax of Errorbar function

조회 수: 1 (최근 30일)
Daniel Campbell
Daniel Campbell 2015년 11월 2일
답변: Nitin Khola 2015년 11월 4일
I have 3 vectors:
time = 1x2035
y=nanmean(matrix), 1x2035,
e=std((Matrix),'omitnan'), 1x2035
I want to plot y by time, and have error bars for each value of y at each time interval. Additionally, I would like to create the same plot, but not include the error bars(so just dots where the error bars would end).
How would I go about this? Thanks in advance!

답변 (1개)

Nitin Khola
Nitin Khola 2015년 11월 4일
My understanding is that in one of the plots you wish to have errorbars and in the other, you want to have some markers at the end points of an errorbar. You can use the "errorbar" function for the former and for the latter, you can create two additional vectors, "y+sigma" and "y-sigma", and plot them simultaneously. To ensure that just the markers show up, set the 'LineStyle' property to 'none'. You can experiment with marker styles. For the example code below, I am using the asterisk symbol as marker.
x = 0:pi/10:pi;
y = sin(x);
e = std(y)*ones(size(x));
figure
% errorbar(x,y,e)
plot(x,y)
y2 = y+e;
y3 = y-e;
hold on
plot(x,y2,'*','LineStyle','none')
plot(x,y3,'*','LineStyle','none')
I hope it helps!

카테고리

Help CenterFile Exchange에서 Errorbars에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by