How to find the average of a single column in matrix
81 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!