Matrix, Mean coloum 2, with a value in coloum 1 < 25

18 vues (au cours des 30 derniers jours)
Kasper Jørgensen
Kasper Jørgensen le 31 Mar 2015
Hello!
I am looking at a 5 x 2 matrix, which i need to mean certain numbers in the secound coloum. But the mean depends on what the value the first coloums has.
Here is the Matrix:
M =
25 0.1090
23 0.0960
15 0.5170
40 0.9340
35 0.1090
For all numbers in coloum 1 < 25, i need to mean the numbers in coloum 2
I have been searching this site for a long time after an answer, but found nothing.
I hope you can help me! :)
Thanks!

Réponse acceptée

Michael Haderlein
Michael Haderlein le 31 Mar 2015
Modifié(e) : Michael Haderlein le 31 Mar 2015
just:
mean(M(M(:,1)<25,2))
The keyword here is logical indexing, btw. You can find good tutorials about it online.
  1 commentaire
Kasper Jørgensen
Kasper Jørgensen le 31 Mar 2015
Thanks, it's working just as intended! :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing 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