Calculate 2 and 3 standard deviations

조회 수: 5 (최근 30일)
Sunshine
Sunshine 2020년 5월 17일
댓글: Steven Lord 2020년 5월 29일
I'm working on calculating 2 and 3 standard deviations to plot on a graph. I'm using the functions mean() and std() for mean and standard deviation calculations. What I'm not understanding is if using std() function provides 1 standard deviation, why use (mean + 2*std()) and (mean + 3*std()) to get the 2 and 3 standard deviations? Would it not be (2*std()) for 2 standard deviations and (3*std()) (that is, without the mean value)? From reading other similar questions/answers here, (mean + 2*std()) and (mean + 3*std()) seems to be correct, but I'm not following why.
  댓글 수: 2
Sunshine
Sunshine 2020년 5월 28일
I think I have found the commands to get started on what I would like to display. I am trying to set the xvalues along the x axis as -3pi to 3pi as an example, and set the y values to the YTick array below. I am not sure what I am doing wrong. I keep getting the error: Array indices must be positive integers or logical values. Am I using XTick, YTick, XTicklabel correctly?
>> clear ax
>> ax = gca;
%c = ax.Color;
%ax.Color = 'blue';
ax.XTick([-3*pi -2*pi -pi 0 pi 2*pi 3*pi]);
ax.XTicklabel({'-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi'});
ax.YTick([-1 -0.8 -0.2 0 0.2 0.8 1]);
%set(gca,'XTick', ax.xtic, 'XTickLabel', ax.xticlab, 'YTick', ax.ytic);
Array indices must be positive integers or logical values.
Steven Lord
Steven Lord 2020년 5월 29일
ax.XTick is not a function that sets the ticks. Either assign to that property or use the xticks function.
ax.XTick = [-3*pi -2*pi -pi 0 pi 2*pi 3*pi]; % or
xticks([-3*pi -2*pi -pi 0 pi 2*pi 3*pi]);
Or to simplify things a little:
ax.XTick = pi*(-3:3);
xticks(pi*(-3:3));
If you look at the See Also section at the end of the documentation page for the xticks function you'll see other similar functions that will be of use to you.
doc xticks

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by