how to calculate row values based on the previous row value of a column?
5 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Chunru
on 15 Nov 2021
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!