Effacer les filtres
Effacer les filtres

How to find the average of a single column in matrix

33 vues (au cours des 30 derniers jours)
Alex Doan
Alex Doan le 5 Fév 2020
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 commentaire
Adam Danz
Adam Danz le 5 Fév 2020
Modifié(e) : Adam Danz le 7 Fév 2020
mean(M(:, size(M,2)))
% or
mean(M(:, end))

Connectez-vous pour commenter.

Réponses (1)

Divya Gaddipati
Divya Gaddipati le 10 Fév 2020
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!

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by