# Standard Deviation And Variance Calculation In MatLab

In data analysis, standard deviation and variance are very important aspects in terms of interpretation of varios datas. These datas can be saved as matrices and vectors in Matlab. So, you can easily calculate the variances and standard deviations of matrices and vectors in Matlab with ‘std()’ and ‘var()’ commands. In here, we explain how to use these commands in Matlab.

## What Is Variance And Standard Deviation?

As you see above, the formulas of variance and standard deviations are very basic. For a lots of datas, calculation of varience and standard deviations can be very troublesome with hand. So, as a good engineer or mathematician, you can use computational methods to calculate them. One of these methods is, using Matlab.

## How To Use ‘std()’ And ‘var()’ Commands In MatLab?

`````` a = [2 6 3; 4 6 3; 11 69 31];
b = [2 65 2 9 46 12 38];
var(a)
%the first
std(a)
%the second
var(b)
%the third
std(b)
%the fourth

ans =

1.0e+03 *

0.0223    1.3230    0.2613

ans =

4.7258   36.3731   16.1658

ans =

615.4762

ans =

24.8088
``````

In command window of Matlab, matrix ‘a’ and vector ‘b’ are created as you see above. And there are four of uses ‘var()’ and ‘std()’ commands.

In the first use of ‘var()’ command above, variance of matrix ‘a’ is directly calculated. All the variance values are calculated for columns of matrix ‘a’. You can check the first answer that appeared in command window in Matlab.