Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个微分方程:da/dt=a(.3/a^3+.7)^1/2 和 dτ/dt=1/a。初始条件为t=0;a=1 和 τ=0,分别。Matlab中的方程怎么解?我需要计算 a、t 和 τ 的不同值,还绘制 τ 与 a。谢谢。
这很容易。
首先编写一个函数来实现你的微分方程,并用与函数名对应的文件名保存它:
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
然后在 MATLAB 中,ode45使用您的函数调用求解器
ode45
[t,y] = ode45(@my_ode,[0 10],[1; 0]);
这是结果: