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

조회 수: 11 (최근 30일)
Masoud Taleb
Masoud Taleb 2022년 4월 24일
댓글: Masoud Taleb 2022년 4월 24일
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

채택된 답변

Matt J
Matt J 2022년 4월 24일
mean (A(:,2:3),2)
  댓글 수: 1
Masoud Taleb
Masoud Taleb 2022년 4월 24일
Thank you very much, it works nice! I learnt the missing part :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by