I want to multiply a vector by a number and calculate the sum of all the values.
Ältere Kommentare anzeigen
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?
Antworten (1)
A = [18;15;125;48;78;69;48;15;12;2];
s = cumsum(A)
Kategorien
Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!