Alternative for a for loop. How would I write this code without using a for loop?
Mostrar comentarios más antiguos
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 comentarios
Matt J
el 2 de Nov. de 2017
There are already no for loops in the code that you've shown.
John Barber
el 2 de Nov. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!