필터 지우기
필터 지우기

Cumulatively sum numbers in an array between two indices

조회 수: 10 (최근 30일)
TOK
TOK 2021년 3월 31일
댓글: TOK 2021년 3월 31일
Hi,
Lets say I have an array with 10 positions as in the picture, for example.
I want to add all the numbers between Index 4 and index 8, and get my answer of 150
What would be the best way of going about this?
Thanks

채택된 답변

DGM
DGM 2021년 3월 31일
Something like this:
x=5:5:50
sum(x(4:8))
  댓글 수: 1
TOK
TOK 2021년 3월 31일
Perfect, thank you very much. I knew it was something quite simple but I just couldn't find or work it out!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by