How to rewrite recursive funtion without for-loop
이전 댓글 표시
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!