Filter löschen
Filter löschen

How to average every row of several columns in a matrix?

15 Ansichten (letzte 30 Tage)
Masoud Taleb
Masoud Taleb am 24 Apr. 2022
Kommentiert: Masoud Taleb am 24 Apr. 2022
Hello
I have matrix that has 1000 columns. I want to average the data of some desired columns. For example if the matrix A is like this:
A = 1 2 4 2 2 3 5
3 5 6 3 2 7 8
2 8 4 8 9 2 1
I want the average of column 2 and 3 apears as:
3
5.5
6
I tried to used "mean (A,2)" but it avareges whole columns that is not what I want. Can anyone help in this?
Thanks in advance

Akzeptierte Antwort

Matt J
Matt J am 24 Apr. 2022
mean (A(:,2:3),2)

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics 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!

Translated by