Borrar filtros
Borrar filtros

Calculate 2 and 3 standard deviations

14 visualizaciones (últimos 30 días)
Sunshine
Sunshine el 17 de Mayo de 2020
Comentada: Steven Lord el 29 de Mayo de 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 comentarios
Sunshine
Sunshine el 28 de Mayo de 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 el 29 de Mayo de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by