sine approximation using a loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
The link above should have my work on it could someone help explain what I am doing wrong.
2 comentarios
Yogesh Bhambhwani
el 30 de Sept. de 2020
Editada: Walter Roberson
el 1 de Oct. de 2020
Respuestas (1)
Walter Roberson
el 1 de Oct. de 2020
Editada: Walter Roberson
el 1 de Oct. de 2020
x = pi/2;
That is overriding the user input about the value to find the sine of.
function [s] = prob3_2(x,N)
You never use the user input N
n = 1;
you have a variable named n which is confusing considering the input named N
while error >= 1*(10^-3);
You are proceeding until your error is in a certain range, but the problem requirement says
% takes a scalar angle measure x (in radians) and estimates sin(x) using
% the first N terms of an alternating series
so you are not intended to go until error is a particular range: you are to go until you have used a particular number of terms.
error = abs((sin(x)-s)/sin(x))*100;
Is error a percentage, or is an absolute value?
What about the cases where sin(x) = 0 ? You would be dividing by 0, which is not going to give you a useful error measure.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!