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

 采纳的回答

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

2 个评论

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

请先登录,再进行评论。

更多回答(2 个)

Marcel Król
Marcel Król 2020-6-5

0 个投票

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

类别

帮助中心File Exchange 中查找有关 Simulink 的更多信息

产品

版本

R2020a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by