sum in matlab coding
조회 수: 2 (최근 30일)
이전 댓글 표시
what is the difference between
sum(a(1):a(3)) and sum(a(1:3))?
댓글 수: 0
채택된 답변
DGM
2022년 2월 12일
편집: DGM
2022년 2월 12일
The first case is summing a linear increasing series between two values stored in a vector. The second is the sum of a subvector within a vector.
a = [5 -10 15 -20]
a(1):a(3) % linear vector from 5 to 20 in steps of 1
a(1:3) % elements 1 through 3 of the vector a
sum(a(1):a(3))
sum(a(1:3))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numeric Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!