Matlab - third-order differential equation solution

y''' + 41y'' + 360y' + 900y = 600x' + 1200x; y(0)= 2 ; y'(0)= 1 ; y''(0) = -0.05 

How can I solve this equation using the ODE45 function?

I tried this:

 ==> function dydt=f(t,y) dydt = [y(2) ; y(3) ; -41*y(3)-360*y(2)- 900*y(1)] ==> clear all; timerange=[0 1.4]; %seconds initialvalues=[2 1 -0.05]; [t,y]=ode45(@dydt, timerange, initialvalues) plot(t,y(:,1)); 

But I need to put the X-part in the equation - I do not know how ...

+6
source share
1 answer

To use ODE45 (or similar), you need to convert a third-order ODE to a first-order ODE system.

To do this, let

 y0 = y y1 = y0' y2 = y1' y3 = y2' 

Then

 y0' = y1 y1' = y2 y2' = y3 

and

 y3' = y''' = -41*y2-360y1-900y0+600dx+1200x 

Now you can use ODE45 to integrate the system by inserting a function where x (t) and dx (t) are available.

 function test() % some random x function x = @(t) exp(-t); dx = @(t) -exp(-t); % integrate numerically [T, Y] = ode45(@linearized, [0 1], [2 1 -0.05 0]); % plot the result plot(T, Y(:,1)) % linearized ode function dy = linearized(t,y) dy = zeros(4,1); dy(1) = y(2); dy(2) = y(3); dy(3) = y(4); dy(4) = -41*y(3)-360*y(2)-900*y(1)+600*dx(t)+1200*x(t); end end 

plot

+3
source

All Articles