I am trying to calculate mean of all the columns in my matrix. Help me please?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am really new to coding and this might seem like a basic question. I am trying to calculate means of individual columns in my matrix and I want to run a loop to do that.
eg.
5 6 6 7 8 9 5 5 3 2 5 7 3 9 8 8 0 7 7 7 8 8 4 4
Basically I want the answers to be in the format
4 6.75 6.125..........
thanks
0 Kommentare
Akzeptierte Antwort
meihua
am 2 Aug. 2013
>> a=[1 2 3; 1 2 3]
a =
1 2 3
1 2 3
>> mean(a,1)
ans =
1 2 3
The help section is extremely useful. You might consider using that first.
2 Kommentare
Jan
am 5 Aug. 2013
No, 5 could not be 6,7,8,9. 5 is 5. Please rephrase the question, if this guess does not match your needs:
m = mean(a(1:5, :), 1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!