Matlab-解三阶微分方程 [英] Matlab - solving a third order differential equation

查看:1059
本文介绍了Matlab-解三阶微分方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

如何使用ODE45函数求解此方程式?

How can I solve this equation using the ODE45 function?

我尝试过:

==>
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));

但是我需要将X部分放在等式中-我不知道如何...

But I need put the X part in the equation - I don't know how...

推荐答案

要使用ODE45(或类似版本),您需要将三阶ODE转换为一阶ODE系统.

To use ODE45 (or similar) you need to convert the third order ODE into a system of first order ODEs.

为此,让

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

然后

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

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

现在,您可以通过嵌套x(t)和dx(t)可用的函数来使用ODE45集成系统.

you can now use ODE45 to integrate the system by nesting the 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

这篇关于Matlab-解三阶微分方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆