Info
This question is locked. Vuélvala a abrir para editarla o responderla.
The question is here http://i.imgur.com/EkSTC0x.png?1
481 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Leonardo Concepcion
el 29 de Oct. de 2013
Locked: DGM
el 9 de Nov. de 2024
I need help to create this program, and I have to prepare this program for tomorrow, can't someone help me?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1805353/image.png)
3 comentarios
Respuesta aceptada
sixwwwwww
el 30 de Oct. de 2013
Dear Leonardo, here is the code for this problem:
x_deg = input('Input angle in degrees: ');
x = degtorad(x_deg);
sumTerms = 0;
n = 0;
E = Inf;
while E > 1e-6
a = ((-1)^n * x^(2 * n + 1)) / factorial(2 * n + 1);
prevSum = sumTerms;
sumTerms = sumTerms + a;
if n ~= 0
E = abs((sumTerms - prevSum) / prevSum);
end
n = n + 1;
end
fprintf('Value of sin(%0.1f) is: %0.5f\n', x_deg, sumTerms)
I hope it helps. Good luck!
6 comentarios
Más respuestas (0)
This question is locked.
Ver también
Categorías
Más información sobre Startup and Shutdown 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!