Solve a nonlinear differential system

1 次查看(过去 30 天)
Hi everyone,
I have problem to plot the next system for the use of an ode45. The two functions are y(t) and x(t) with "t" the variable. The system of equation is the next one:
ay''' - b*x*y' + w*cos(y) = 0
x' - w*L*sin(y)=0
a,b,w and L are constant
If anyone can help thanks a lot for your time.

回答(1 个)

Areej Varamban Kallan
Hi Rahiti,
I understand that you need help in solving nonlinear system of differential equations using 'ode45'. To use 'ode45' the governing equations should be of the form X' = F(X,t), where X and F are vectors. Your system of equations can be recast into this form as follows:
  1. Let x1 = x and x2 = y
  2. x1' = wLsin(x2)
  3. x2' = x3
  4. x3' = x4
  5. x4' = (bx1x3-wcos(x2))/a
Define these derivatives in a separate function file (func.m) and pass its handle as an argument to ode45.
function dxdt=func(t,x)
a=1;
b=0.2;
w=1;
L=0.1;
dx1dt=w*L*sin(x(2));
dx2dt=x(3);
dx3dt=x(4);
dx4dt=(b*x(1)*x(3)-w*cos(x(2)))/a;
dxdt=[dx1dt;dx2dt;dx3dt;dx4dt];
end
A sample execution is shown below
tspan = [0 5] % time interval in which equations are solved
X0 = [1 1 0 0] % initial values of x1, x2 , x3 and x4 (or x, y, y', y'')
[t,X]=ode45(@func,tspan, X0)

类别

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