Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
standard deviation error

Subject: standard deviation error

From: Kirk

Date: 10 Aug, 2011 13:06:10

Message: 1 of 4

I am getting the following from std() on a 150X100 matrix

s = std(dl_aspn_fixed_npp_1x,2)
??? Error using ==> var at 95
W must be a vector of nonnegative weights, or a scalar 0 or 1.

Error in ==> std at 32
y = sqrt(var(varargin{:}));

I don't think there are any negative values (min reports 644.256 and max reports 1.05e+03) and the functiontion:

y = mean(dl_aspn_fixed_npp_1x,2);

works as expected. Any ideas as to what might be going on? Thanks

Subject: standard deviation error

From: Steven_Lord

Date: 10 Aug, 2011 13:14:33

Message: 2 of 4



"Kirk" <kwythers.nospam@umn.edu> wrote in message
news:j1tvo2$3dl$1@newscl01ah.mathworks.com...
> I am getting the following from std() on a 150X100 matrix
>
> s = std(dl_aspn_fixed_npp_1x,2)
> ??? Error using ==> var at 95
> W must be a vector of nonnegative weights, or a scalar 0 or 1.

Look at the documentation for STD:

http://www.mathworks.com/help/techdoc/ref/std.html

What is the meaning of the second input argument? What values does the
documentation indicate this flag can take on? Is 2 one of those allowed
values?

> Error in ==> std at 32
> y = sqrt(var(varargin{:}));
>
> I don't think there are any negative values (min reports 644.256 and max
> reports 1.05e+03) and the functiontion:
> y = mean(dl_aspn_fixed_npp_1x,2);
>
> works as expected. Any ideas as to what might be going on? Thanks

The second input argument to MEAN corresponds to the _third_ input argument
to STD, not the second input to STD.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: standard deviation error

From: Kirk

Date: 10 Aug, 2011 13:29:28

Message: 3 of 4

"Steven_Lord" <slord@mathworks.com> wrote in message <j1u07o$50j$1@newscl01ah.mathworks.com>...
>
>
> "Kirk" <kwythers.nospam@umn.edu> wrote in message
> news:j1tvo2$3dl$1@newscl01ah.mathworks.com...
> > I am getting the following from std() on a 150X100 matrix
> >
> > s = std(dl_aspn_fixed_npp_1x,2)
> > ??? Error using ==> var at 95
> > W must be a vector of nonnegative weights, or a scalar 0 or 1.
>
> Look at the documentation for STD:
>
> http://www.mathworks.com/help/techdoc/ref/std.html
>
> What is the meaning of the second input argument? What values does the
> documentation indicate this flag can take on? Is 2 one of those allowed
> values?
>
> > Error in ==> std at 32
> > y = sqrt(var(varargin{:}));
> >
> > I don't think there are any negative values (min reports 644.256 and max
> > reports 1.05e+03) and the functiontion:
> > y = mean(dl_aspn_fixed_npp_1x,2);
> >
> > works as expected. Any ideas as to what might be going on? Thanks
>
> The second input argument to MEAN corresponds to the _third_ input argument
> to STD, not the second input to STD.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


I did look at the documentation. Perhaps I am misinterpreting the text, "s = std(X,flag) for flag = 0, is the same as std(X). For flag = 1, std(X,1) returns the standard deviation using (2) above, producing the second moment of the set of values about their mean"

I am intending to use flag = 1, (first method), so I left that argument out. Also I want the function calculated along the along the 2nd dimension, so I used that argument (2).

Perhaps what the help docs mean is:

If you are going the use the third argument, you must use the second argument. Otherwise MATLAB will not know the the second value is the third argument.

Thanks Steve

Subject: standard deviation error

From: Steven_Lord

Date: 10 Aug, 2011 13:45:09

Message: 4 of 4



"Kirk" <kwythers.nospam@umn.edu> wrote in message
news:j1u13o$87h$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <j1u07o$50j$1@newscl01ah.mathworks.com>...

*snip*

> I did look at the documentation. Perhaps I am misinterpreting the text, "s
> = std(X,flag) for flag = 0, is the same as std(X). For flag = 1, std(X,1)
> returns the standard deviation using (2) above, producing the second
> moment of the set of values about their mean"
>
> I am intending to use flag = 1, (first method), so I left that argument
> out.

You can't do that. It would be like me calling you "Krk" -- I intended for
the second letter to be "i" so I left it out. [Okay, kind of a bad example
because the human brain tends to be good at "filling in" the missing details
when confronted with a situation like that. MATLAB, and computer programs in
general, aren't that good.]

> Also I want the function calculated along the along the 2nd dimension, so
> I used that argument (2).
> Perhaps what the help docs mean is:
>
> If you are going the use the third argument, you must use the second
> argument. Otherwise MATLAB will not know the the second value is the third
> argument.

Yes, that is correct. In general, whenever you want to use the Nth input
argument to a function, you must specify something the function recognizes
for the 1st, 2nd, ... (N-1)st inputs.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us