首页 文章

如何在Matlab中求解微分方程组

提问于
浏览
-1

对于家庭作业,我的教授要求我们使用matlab解决微分方程组 . 使用mathworks网站,我做到了

syms f(t) g(t) h(t)
[f(t), g(t), h(t)] = dsolve(diff(f) == .25*g*h,...
diff(g) == -2/3*f*h,...
diff(h) == .5*f*g, f(0) == 1, g(0) == -2, h(0) == 3)

它说一个明确的方程式无法解决...任何帮助表示赞赏谢谢 .

1 回答

  • 0
    %x(1),x(2),x(3)=f,g,h
    
    fun = @(t,x) [0.25*x(2)*x(3); -2/3*x(1)*x(3);
    -0.5*x(1)*x(2)];
    [t,x] = ode45(fun,[0 100],[1 2 3]);
    plot3(x(:,1),x(:,2),x(:,3))
    %x has three columns which contains values of f,g,h as a function of time from %time t=0 to t=100
    %please check ode45 in matlab to see what these arguments mean
    

相关问题