Calculate Average or Mean of a matrix

3 visualizaciones (últimos 30 días)
Minhaz  Parveez
Minhaz Parveez el 24 de Sept. de 2016
Respondida: Maneet Kaur Bagga el 6 de Jul. de 2022
a=[5 2;5 6;8 8]; How to calculate the average of this matrix using function?
Answer is like (5+5+8/3,2+6+8/3)

Respuesta aceptada

Image Analyst
Image Analyst el 24 de Sept. de 2016
Try mean():
columnMeans = mean(a, 1)

Más respuestas (1)

Maneet Kaur Bagga
Maneet Kaur Bagga el 6 de Jul. de 2022
As per my understandig you want to calculate the mean of each coloumn of the matrix. By default MATLAB fuctions work on coloumns therefore you can use the mean function directly. Please refer to the code below. Hope it helps!
X = [5 2;5 6;8 8]
X = 3×2
5 2 5 6 8 8
mean(X)
ans = 1×2
6.0000 5.3333

Categorías

Más información sobre Spline Postprocessing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by