# Variance Calculation For Vectors In MatLab®(Illustrated Expression)

Variance calculation is somewhat important in Linear Algebra for vectors and matrices. You know that MatLab® is a very versatile software for Linear Algebra calculations. So variance calculations of vectors and matrices are very basic in Matlab®. This article shows how to calculate the variance of vectors and matrices in Matlab®.

## How To Calculate Variance Values Of Matrices And Vectors In MatLab®?

``````>> a = [2 6 2 64 23 45 632 45 6823]
b = [263 62 626; 65 56 562; 5412 12621 23]
var(a)
var(b)

a =

2           6           2          64          23          45         632          45        6823

b =

263          62         626
65          56         562
5412       12621          23

ans =

5.059070611111110e+06

ans =

1.0e+07 *

0.919030233333333   5.260129033333333   0.010970433333333

>> ``````

We created an ‘a’ vector and ‘b’ matrix, then we took their variances as shown above.

The variance value is taken as one value as shown above. So this means that there is one variance calculation of vectors in Matlab® with the ‘var()’ command.

Also if you look at the variance calculation of the ‘b’ matrix as shown above, there is a three value. So each row’s variance values of a matrix are calculated separately with the ‘var()’ command.

## Conclusion

So the calculation of variance values in Matlab® is very simple like that.

Do not forget to leave your comments and questions below about the use of the var() command in Matlab® below.

If you want further coding examples about the var() command in Matlab®, inform us in the comments.