Borrar filtros
Borrar filtros

Using a for loop to compute a Taylor series of sine?

3 visualizaciones (últimos 30 días)
Aaron Zorzi
Aaron Zorzi el 8 de Oct. de 2015
Comentada: Esteban Gómez el 20 de En. de 2021
I understand while loops pretty well, but for loops always seem to throw me off. Can someone please help me? Thanks.
  2 comentarios
James Tursa
James Tursa el 8 de Oct. de 2015
Please make an attempt and post your code, and then ask specific questions about it. Then we can comment on it and make suggestions.
Aaron Zorzi
Aaron Zorzi el 8 de Oct. de 2015
I would but I honestly have no clue where to begin. I understand how to ask for the input statements and make the fprintf statements, but that is all. I'm entirely lost.

Iniciar sesión para comentar.

Respuesta aceptada

Stalin Samuel
Stalin Samuel el 8 de Oct. de 2015
%%sample code
prompt = 'Enter angle value between 0 to 2pi? ';
x = input(prompt)
prompt = 'Enter the no of terms? ';
N = input(prompt)
ty = 0;
for i = 1:N
ty = ty +((-1)^(i))*((x^(2*i+1))/(factorial(2*i+1)));%your calculations
end
fprintf(['actual value ' num2str(ty)]) %display the results

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by