In data analysis, standard deviation and variance are very important aspects in terms of the interpretation of various data. These data 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. Here, we explain how to use these commands in Matlab®.
If you are interested to learn MATLAB® at an engineering level, click on the given link or the ‘Shop Now’ button to check the recommended book by Mechanicalland, from Amazon!
On this post
What Is Variance And Standard Deviation?

As you see above, the formulas of variance and standard deviations are very basic. For a lot of data, calculation of variance 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 the 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 the ‘var()’ command above, the 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 the command window in Matlab®.
The second one is about the calculation of the standard deviation of the matrix ‘a’. The standard deviation is also calculated for all rows for matrix ‘a’. Chech the second answer above.
The third one is about the use of the ‘var()’ command in Matlab® for vector ‘b’. As you see calculation is very basic, the variance value is calculated. The same logic is also valid for the standard deviation above as you see. Check the third and fourth answers respectively.
YOU CAN LEARN Matlab® IN MECHANICAL BASE; Click And Start To Learn Matlab®!
Conclusion
As you see, the use of ‘std()’ and ‘var()’ commands are very basic in Matlab® to calculate standard deviations and variances of matrices and vectors. Do not forget to leave your comments and questions about ‘var()’ and ‘std()’ commands in Matlab® below.
Your precious feedbacks are very important for us.
Leave a Reply