Integrating sin(2x) in MATLAB

조회 수: 15 (최근 30일)
Shane Yost
Shane Yost 2013년 7월 8일
Introduction:
I'm new to MATLAB and trying to learn how to integrate expressions.
Situation:
The expression to integrate is.....
sin(2x)
I'm entering the following code......
syms x
int(sin(2*x))
The answer MATLAB is displaying is.....
ans =
sin(x)^2
The answer I'm looking for is....... (-1/2)*cos(2x)+c

채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 7월 9일
syms x
out = feval(symengine,'combine',int(sin(2*x)),'sincos')

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 7월 9일
(-1/2)*cos(2x)=(-1/2)*(cos^2(x)-sin^2(x))
=(-1/2)*(1-sin^2(x)-sin^2(x))
=(-1/2)+sin^2(x)
=sin^2(x)+c
The result found by Matlab and yours are the same
  댓글 수: 1
Jan
Jan 2013년 7월 9일
@Shane Yost: Interesting, isn't it? Matlab replied the correct result, but you've expected another correct result.

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

카테고리

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