How to rewrite recursive funtion without for-loop
Show older comments
Hi, I am struggling with a recursive function that includes multiplication as well as a vector. Is there a way to speed up performance and rewrite the calculation (probably without using a for-loop):
a=1:20;
b=5;
c=3;
x=zeros(size(a,2),1);
for i=3:size(x,1)
x(i)=a(1,i)+b*x(i-1)+c*x(i-2);
end
Many thanks for any help.
1 Comment
Pascal
on 9 Sep 2016
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!