use the for or while looping to the series S=4*[sin(theata)/1 +sin(3theata)/3+sin(5theata)/5+.....] ,,in the range 0<theata<pi with error bound of 10^-6..?....please help me to solve this question in the earliest opportunity
Mostrar comentarios más antiguos
S=4*[sin(theata)/1 +sin(3theata)/3+sin(5theata)/5+.....]
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 15 de Abr. de 2013
0 votos
Hint, have a loop over k and calculate sin(k*theata)/k in the loop. I hope that's not doing too much of your homework for you. You still have to make the loop and sum up the term in the loop into the overall sum and then multiply that by 4.
2 comentarios
majid
el 15 de Abr. de 2013
Editada: Image Analyst
el 15 de Abr. de 2013
Image Analyst
el 15 de Abr. de 2013
Use a for loop instead of a while loop. Have an outer for loop over theata.
for theata = 0: 0.01 : pi
Don't use "sum" since that is a built in function name and you'll be destroying it. Use S like you started to. Finally you need to calculate the "true" value (whatever that is) and compare it to S and bail out of your inner for loop once the error is less than 1E-6.
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!