フィルターのクリア

How to find the average of a single column in matrix

33 ビュー (過去 30 日間)
Alex Doan
Alex Doan 2020 年 2 月 5 日
回答済み: Divya Gaddipati 2020 年 2 月 10 日
i have a 17x6 matrix and i want to find the average of the last column WITHOUT hardcoding meaning if that matrix becomes a 16x4 it will still calculate the avg
  1 件のコメント
Adam Danz
Adam Danz 2020 年 2 月 5 日
編集済み: Adam Danz 2020 年 2 月 7 日
mean(M(:, size(M,2)))
% or
mean(M(:, end))

サインインしてコメントする。

回答 (1 件)

Divya Gaddipati
Divya Gaddipati 2020 年 2 月 10 日
Hi,
If m is your matrix, to get the last column and mean, you can use:
last_col = m(:, end)
avg = mean(last_col);
Hope this helps!

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by