MATLAB: How to calculate standard deviation of 1D array

standard deviationstdstd of 1d arraystd2

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.

Best Answer

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.
Related Question