Hi, how can I set up this kind of system? My X vector has 84 elements, I want to implement this system :
z1 = 100 + X(1);
z2 = z1 + X(2);
z3 = z2 + X(3);
z4 = z3 + X(4);
etc...for 84 elemens
thanks in advance

 採用された回答

John D'Errico
John D'Errico 2019 年 5 月 5 日

0 投票

Don't create a list of 84 distinct numbered variables. This is a bad idea, terribly poor programming style. It willl create buggy code, and slow code if you try to use those variables.
However, it is trivial to create a new vector with that property.
z = cumsum(X);
z(1) = z(1) + 100;

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by