solving ordinary differential equations

조회 수: 12 (최근 30일)
abdallah alwohoush
abdallah alwohoush 2021년 12월 31일
편집: Torsten 2021년 12월 31일
Hello, I'm a beginner in matlab. I'm trying to solve ODE in matlab, but I'm getting error I don't know why!
This is the equation d2y(t) / dt2 + 2 dy/dt + 5 y(t) = 5 cos1500t, I attached a photo of my code with the errors.
  댓글 수: 1
Torsten
Torsten 2021년 12월 31일
편집: Torsten 2021년 12월 31일
Which MATLAB version do you use ?
The syntax for using "dsolve" has changed in the course of time.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 12월 31일
I think the reason for the error is that you have defined dy as a sym variable rather than a symfun, so it is interpretting the '(0)' to be an index into variable dy rather than dy at t==0.
Try this
syms y(t)
dy(t) = diff(y(t),t)
dy(t) = 
dy2(t) = diff(y(t),t,2)
dy2(t) = 
equation = dy2 + 2*dy + 5*y(t) == 5*cos(1500*t)
equation(t) = 
i1 = y(0) == 0;
i2 = dy(0) == 0;
dsolve(equation,[i1,i2])
ans = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by