How to solve coupled differential equation in matlab using ode45

橙三吉。 提交于 2019-12-11 17:16:18

问题


I have two differential equations: da/dt=a(.3/a^3+.7)^1/2 and dτ/dt=1/a. The initial conditions are t=0; a=1 and τ=0, respectively. How can I solve the equations in Matlab? I need to calculate different values of a, t and τ also plot τ vs a. Thanks.


回答1:


That's quite easy.

First write a function to implement your differential equation and save it with a filename corresponding to the function name:

function dy = my_ode(t,y)
dy(1) = y(1)*(0.3/y(1)^3 + 0.)^(1/2); % a
dy(2) = 1/dy(1); % tau

Then in MATLAB, call the ode45 solver with your function

[t,y] = ode45(@my_ode,[0 10],[1; 0]);

This is the result:



来源:https://stackoverflow.com/questions/53519305/how-to-solve-coupled-differential-equation-in-matlab-using-ode45

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!