Dynamic system using ode45

조회 수: 9 (최근 30일)
Michelle Westin
Michelle Westin 2020년 4월 20일
댓글: Michelle Westin 2020년 4월 21일
Hi,
I need to solve the following function:
function X2d = dynamics(h,theta,beta,hd,thetad,betad,Mt,Ct,Kt,hdd,thetadd,betadd)
X = [h;theta;beta;hd;thetad;betad;hdd;thetadd;betadd];
h = X(1);
theta = X(2);
beta = X(3);
hd = X(4);
thetad = X(5);
betad = X(6);
hdd = X(7);
thetadd = X(8);
betadd = X(9);
X1 = [X(1);X(2);X(3)];
X2 = [X(4);X(5);X(6)];
X2d = [X(7);X(8);X(9)];
X2d = inv(Mt)*(-Ct*X2-Kt*X1);
end
Where d are dot, so it is a system of differential equations.
How can I solve this? May I use ode45?
Thanks

채택된 답변

Muthu
Muthu 2020년 4월 20일
편집: Muthu 2020년 4월 20일
You first need to convert this function into a form, which can be passed in ode45
To solve using ode45, you need to have three important inputs -> @equation, timerange, initial condition, options
hence your equation should begin like:
function X2d = dynamics(t, Y, options):
Y contains all the initial conditions of the variables.
options contain the arguements that you might need to pass in.
define the constants inside the function.
Then proceed with your code.
Good luck.
  댓글 수: 1
Michelle Westin
Michelle Westin 2020년 4월 21일
Muthu, thank you for yoour answer. Actually I sumarize the problem to post here. There are other functions to generate the matrices I am using.
I will try to implement like you suggested and if I have another problem, I will post here. Also, I will study a bit more about ode45.
Thank you again and regards

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by