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!