Calculate 2 and 3 standard deviations

8 Ansichten (letzte 30 Tage)
Sunshine
Sunshine am 17 Mai 2020
Kommentiert: Steven Lord am 29 Mai 2020
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 Kommentare
Sunshine
Sunshine am 28 Mai 2020
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 am 29 Mai 2020
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by