필터 지우기
필터 지우기

Using dsolve function to solve this equation?

조회 수: 1 (최근 30일)
Bob
Bob 2016년 7월 23일
댓글: Star Strider 2016년 7월 23일
Question: Use dsolve to solve this equation: y' − y = 2 sin(t).
Below is the code I used but I do not think I am getting the right answer.
syms y(t);
y = dsolve(diff(y) == 2*sin(t)+y)

채택된 답변

Star Strider
Star Strider 2016년 7월 23일
For grins, I decided to see what a Laplace transform solution would produce:
syms s y(t) y0 Y
Lsin = laplace(sin(t));
Eqn1 = Y*(s-1) == Lsin;
Eqn2 = solve(Eqn1, Y);
Eqn3 = ilaplace(partfrac(Eqn2))
Eqn4 = simplify(Eqn3, 'steps',10)
Eqn3 =
exp(t)/2 - cos(t)/2 - sin(t)/2
Eqn4 =
exp(t)/2 - (2^(1/2)*sin(t + pi/4))/2
  댓글 수: 2
Bob
Bob 2016년 7월 23일
I need to use the dsolve function, so this does not help me at all.
Star Strider
Star Strider 2016년 7월 23일
My point is that it gives an equivalent answer to the answer dsolve returns when you simplify it. It assumes an initial condition of zero. If you want to specify an initial condition, include one:
syms y(t) y0
y = dsolve(diff(y) == 2*sin(t)+y, y(0) == y0)
y =
exp(t)*(y0 + 1) - 2^(1/2)*cos(t - pi/4)

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by