Alternative for a for loop. How would I write this code without using a for loop?
이전 댓글 표시
function approx = approxCosineFunction(x, t)
approx=1;
for i=1:1:t-1
addterm = (-1)^i*(x^(2*i))/factorial(2*i);
approx = approx + addterm;
end
end
댓글 수: 2
Matt J
2017년 11월 2일
There are already no for loops in the code that you've shown.
John Barber
2017년 11월 2일
채택된 답변
추가 답변 (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!