Borrar filtros
Borrar filtros

how can I solve this problem

1 visualización (últimos 30 días)
alhinai thuraiya
alhinai thuraiya el 10 de Oct. de 2016
Respondida: Guðmundur el 11 de Oct. de 2016
The cosine function can be evaluated by the following infinite series: cosx=1-(x^2)/2!+(x^4)/4!-(x^6)/6!+..... Write a MATLAB code to implement this formula in order to compute the value of cosx up to any n order term (i.e. x=pi/5,n=10)
  1 comentario
James Tursa
James Tursa el 10 de Oct. de 2016
What have you done so far? What specific problems are you having with your code?

Iniciar sesión para comentar.

Respuestas (1)

Guðmundur
Guðmundur el 11 de Oct. de 2016
n = 10;
x = pi/5;
m = 0:2:2*n;
s = ones(1,n+1);
s(2:2:end) = -1;
cosx = sum((x.^m./factorial(m)).*s);

Categorías

Más información sobre Programming 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