Hi, i want to sum each 3 columns of my array for any array dimension.
For example, Y array is the sum of each X array respectively to its color.
Need this to do sum for Nx150 array, so that it can turn into Nx50 array
Thanks!

 채택된 답변

David Hill
David Hill 2021년 10월 14일

1 개 추천

m=movsum(x,3);
y=m(:,1:3:end);

댓글 수: 3

ang bn
ang bn 2021년 10월 14일
편집: ang bn 2021년 10월 14일
I'm sorry, is "movesum" a new function? because i couldnt find it in my matlab (r2015a)
thanks
Edit:
I just knew we can do matlab online, and it works perfectly, thank you so much!
Walter Roberson
Walter Roberson 2021년 10월 14일
movsum is R2016a and newer
ang bn
ang bn 2021년 10월 14일
okay now I'll just do matlab online, maybe later I will install newer version
thanks!

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 10월 15일

1 개 추천

reshape(x, size(x,1), 3, [])
now you can sum along the second dimension, and then reshape to remove the now-singular second dimension.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2015a

질문:

2021년 10월 14일

답변:

2021년 10월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by