how to calculate standard deviation of 1D array?

23 次查看(过去 30 天)
i have an array A.
A=[1 2 3 4];
s=std(A);
Error: Index exceeds matrix dimensions.
  • sometimes std says: Subscript indices must either be real positive integers or logicals.
  • and also what is the difference in std and std2.

采纳的回答

Star Strider
Star Strider 2014-7-10
编辑:Star Strider 2014-7-10
1. You most likely have a variable named std. This command should give you that information (copy-paste it to the Command Window and run it):
which std -all
If you have a Windows computer, all those results should be in the C:\Program Files\MATLAB\... directories, and none in your user files or as variables.
2. The std function takes the standard deviation across the columns (or rows) of an array, producing one value for each column (or row). The std2 function takes the standard deviation of all the elements in the array, as though they were all a single vector.
  2 个评论
Ayush
Ayush 2014-7-10
Thanks.. Got it working. Std was used somewhere. Restarting matlab, solved the problem.
Star Strider
Star Strider 2014-7-10
My pleasure!
(The most sincere expression of appreciation here on MATLAB Answers is to Accept the Answer that most closely solves your problem.)

请先登录,再进行评论。

更多回答(3 个)

John D'Errico
John D'Errico 2014-7-10
How? Use std to compute a standard deviation. Read the help.
DON'T NAME YOUR VARIABLE STD. If you do, you will get that error message!
As far as the difference between std and std2, MATLAB does not have a std2 function in it. Maybe somebody you know has written a std2 code. I can't guess.

Ayush
Ayush 2014-7-10
Thanks.. Got it working. Std was used somewhere. Restarting matlab, solved the problem.

Ken Irok
Ken Irok 2019-2-20
Hi, I have a 74 row of array stored in my workplace called "feat". How do I calculate the std and mean for each column in that array? Say there is 6 different columns inside that array of workplace.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by