how to calculate row values based on the previous row value of a column?

8 ビュー (過去 30 日間)
Suresh R
Suresh R 2021 年 11 月 15 日
回答済み: Chunru 2021 年 11 月 15 日
input array
a= [1,2,3,4,5,6,7,8,9,10]
the output array is as follows. where 100 is initial value we are calculating for 1. for 2 we are taking output of 1.
b= (1*100)+100 = 200
b = (2*200)+ 200 = 600
b=(3*600)+600 = 2400
like wise i need to calculate for all elements of a.

採用された回答

Chunru
Chunru 2021 年 11 月 15 日
a= [1,2,3,4,5,6,7,8,9,10];
b = 100; % initial value
for i=1:numel(a)
b= (a(i)*b)+b;
fprintf("i=%2d b=%d\n", i, b)
end
i= 1 b=200 i= 2 b=600 i= 3 b=2400 i= 4 b=12000 i= 5 b=72000 i= 6 b=504000 i= 7 b=4032000 i= 8 b=36288000 i= 9 b=362880000 i=10 b=3991680000

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by