Hey!
How can I create such a vector:
[1,1+2,1+2+3, ... ,1+2+3+...+n]
without a loop?

 Accepted Answer

Try this:
v = 1:n;
vs = cumsum(v)
.

2 Comments

Thank you very much :)
As always, my pleasure!

Sign in to comment.

More Answers (2)

a=1:n;
A=a.*(a+1)/2;
Marcel Król
Marcel Król on 5 Jun 2020

0 votes

cześć
Jak mogę stworzyć wektor kolumnowy n elementowy? Proszę o pomoc

1 Comment

Możesz stworzyć macierz jednokolumnową.

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2020a

Tags

Community Treasure Hunt

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

Start Hunting!