Calculate Average or Mean of a matrix

2 ビュー (過去 30 日間)
Minhaz  Parveez
Minhaz Parveez 2016 年 9 月 24 日
回答済み: Maneet Kaur Bagga 2022 年 7 月 6 日
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)

採用された回答

Image Analyst
Image Analyst 2016 年 9 月 24 日
Try mean():
columnMeans = mean(a, 1)

その他の回答 (1 件)

Maneet Kaur Bagga
Maneet Kaur Bagga 2022 年 7 月 6 日
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

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by