How to write cumulative product function
2 views (last 30 days)
Show older comments
Life is Wonderful
on 15 Mar 2022
Commented: Life is Wonderful
on 16 Mar 2022
Hi
I am trying to implement cumproduct without using built-in function. Below is my test code . I need help to implement "My Test code " like built-in cumprod([1 1 2 : 5]).
Thank you!!
% Built-in
A = cumprod([1 1 2 : 5])
% A
%------+
% 1
% 1
% 2
% 6
% 24
% 120
% My Test code ,
A1 = 1;
for i = 1 :5
A1 = A1 * i;
fprintf('%10d|%10d|\n',i,A1);
end
A1
-----+
1|
2|
6|
24|
120|
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Hypothesis Tests 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!