Info

This question is locked. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

The question is here http://i.i​mgur.com/E​kSTC0x.png​?1

조회 수: 42 (최근 30일)
Leonardo Concepcion
Leonardo Concepcion 2013년 10월 29일
Locked: DGM 2024년 11월 9일
I need help to create this program, and I have to prepare this program for tomorrow, can't someone help me?
  댓글 수: 3
Leonardo Concepcion
Leonardo Concepcion 2013년 10월 29일
the output doesn't give us the value and I know I have some mistakes. I only need the program to display the value of sin(x)

채택된 답변

sixwwwwww
sixwwwwww 2013년 10월 30일
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
Leonardo Concepcion
Leonardo Concepcion 2013년 10월 30일
Yes is better that way!!, thanks for your help :)
Leonardo Concepcion
Leonardo Concepcion 2013년 10월 30일
And the rest of the script is ok?

추가 답변 (0개)

This question is locked.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by