How to create a column vector where each element will be compounded amount by percentage of another vactor?

Hi, suppose that x=[.2 .3 .4]'; I need to create z=[1000 1000*(1+.2) 1000*(1+.2)(1+.3) 1000*(1+.2)(1+.3)(1+.4)]'. This is just an example. My original x variable has thousands of data. Anyone can help please? first value of z can be 1000 or any other arbitrary value.

 採用された回答

You need to use the function cumprod. In your example:
x = [.2 .3 .4]';
z = 1000*[1; cumprod(1+x)];
This will give you what you need.

1 件のコメント

Thank you very much Yoav. It worked perfectly.
Kind regards
Sayeed

サインインしてコメントする。

その他の回答 (1 件)

Mohammad Sayeed
Mohammad Sayeed 2014 年 7 月 15 日
Thank you very much Yoav. It worked perfectly.
Kind regards
Sayeed

カテゴリ

ヘルプ センター および File ExchangeOil, Gas & Petrochemical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by