Help with plotting sin(X) for a taylor series

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 3 de Feb. de 2019
Editada: KALYAN ACHARJYA el 3 de Feb. de 2019
Please check
for i = 0:9
sin_value = sin_value + (-1).^i * input_value^(2.*i+1)/factorial(2.*i+1);
end
end
Is it ok? or It may be
sin_value(i)=..
after iterations finish
plot(x_values, sin_value) %ensure both having same lengths

6 comentarios

William Paik
William Paik el 3 de Feb. de 2019
This is what i got when i changed sin_value= to sin_value(i)
Array indices must be positive integers or logical values.
Error in Problem4_Project1_2019_Fixed>calculate_sin (line 35)
sin_value(i) = sin_value + (-1).^i * x_values^(2.*i+1)/factorial(2.*i+1);
Error in Problem4_Project1_2019_Fixed (line 21)
y_values(j) = calculate_sin(x_values(j));
KALYAN ACHARJYA
KALYAN ACHARJYA el 3 de Feb. de 2019
In for loop start i from 1 to 10
William Paik
William Paik el 3 de Feb. de 2019
but it needs to start at 0 because thats the def of taylor series
Check with
sin_value(i+1)=..same
Before plot, please ensure both (x and sin) have same lengths
William Paik
William Paik el 3 de Feb. de 2019
how do I do that?
KALYAN ACHARJYA
KALYAN ACHARJYA el 3 de Feb. de 2019
Editada: KALYAN ACHARJYA el 3 de Feb. de 2019
I am not asking for do that, just check before plot. Plot x,y, here both must have same lengths

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Preguntada:

el 3 de Feb. de 2019

Editada:

el 3 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by