필터 지우기
필터 지우기

how can I solve this problem

조회 수: 1 (최근 30일)
alhinai thuraiya
alhinai thuraiya 2016년 10월 10일
답변: Guðmundur 2016년 10월 11일
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
James Tursa
James Tursa 2016년 10월 10일
What have you done so far? What specific problems are you having with your code?

댓글을 달려면 로그인하십시오.

답변 (1개)

Guðmundur
Guðmundur 2016년 10월 11일
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);

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by