フィルターのクリア

I want to multiply a vector by a number and calculate the sum of all the values.

2 ビュー (過去 30 日間)
Seyed Navid Shoaiby
Seyed Navid Shoaiby 2022 年 12 月 11 日
回答済み: Torsten 2022 年 12 月 11 日
I have a vector, and I want to calculate the sum of the values at each step. For example, A = [18;15;125;48;78;69;48;15;12;2]. I want to calculate the sum of the values in a vector. I mean, I want C = [18;18+15;18+15+125;18+15+125+48;...]. How can I do that?

回答 (1 件)

Torsten
Torsten 2022 年 12 月 11 日
A = [18;15;125;48;78;69;48;15;12;2];
s = cumsum(A)
s = 10×1
18 33 158 206 284 353 401 416 428 430

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by