MATLAB mean

mean( ) command or function gives the mean or average value of vector or matrix or array elements, after reading this MATLAB mean topic, you will know the theory and examples.


Syntax:

mean(n)

  • n can be a vector or matrix.

Example: To calculate the mean of vector elements.

% create a vector n
n=[1,2]; 
mean(n)

Output:

ans =

1.5000

Example: To create a matrix and calculates the mean of each column.

% create the 3x3 matrix as 
n=[1,2,3;3,2,1;4,5,1] 

v=mean(n)

Output:

n =

     1     2     3
     3     2     1
     4     5     1


v =

    2.6667    3.0000    1.6667

Explanation:

  • 2.6667, 3.0000 and 1.6667 is the mean value of the first, second and third column elements respectively.

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *