sum in matlab coding
3 ビュー (過去 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!