Matlab → Basics → Arrays → Statistical Functions
Matlab has several useful built-in statistical functions. For example, consider a vector A, where A=[5 9 2 4]
and we are interested in finding mean and variance of this data set. It can easily be done in Matlab using the commands mean
and var
. For example,
>> A=[5 9 2 4];
>> mean(A)
ans =
5
>> var(A)
ans =
8.6667
The next Table shows some more useful Matlab built-in statistical functions.
Command | Description | Answer |
>> A=[5 9 2 4]; |
Calculate sum of the vector A. | 20 |
>> A=[5 9 2 4]; |
Calculate mean (or average) of the vector A. Note that mean is used for arithmetic average. | 5 |
>> A=[5 9 2 4]; |
Calculate geometric mean of the vector A. | 4.3559 |
>> A=[5 9 2 4]; |
Arrange the vector A in ascending order. | 2 4 5 9 |
>> A=[5 9 2 4]; |
Calculate median of the vector A. | 4.5000 |
>> A=[5 9 2 4]; |
Calculate standard deviation of the vector A. | 2.9439 |
>> A=[5 9 2 4]; |
Calculate variance of the vector A. | 8.6667 |
>> A=[5 9 2 4]; |
Calculate cumulative sum of the vector A. That is, 5, 5+9=14, 14+2=16, 16+4=20 |
5 14 16 20 |
>> normcdf(0.3519) |
The command normcdf returns the cumulative probability distribution function for a standardized normal distribution. |
0.6375 |