Error using ODE45
显示 更早的评论
I have an ode for density that is a function of mass flow, volume, density and the time derivative of the volume. Since the volume varies as a sine function I'm expecting the densities to oscillate around the initial value, but instead it increases. Does anyone know what is causing this error and what can be done to fix it?
D0=[70 80];
tspan=[0 50];
[t T]=ode45(@DensFunc, tspan, D0);
function Dx=DensFunc(t, D)
A=0.02;f=100;w=2*pi*f;
y=A*sin(w*t);v=w*A*cos(w*t);
a1=2e-3;
a2=1.5e-3;
VA=a1*(0.024+y);
VB=a2*(0.024-y);
dotVA=a1*v;
dotVB=-a2*v;
%setting the massflow equal to zero to find out whats wrong.
dotmA=0;
dotmB=0;
Dx=zeros(2,1);
Dx(1)=((dotmA-D(1)*dotVA)/(VA));
Dx(2)=((dotmB-D(2)*dotVB)/(VB));
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!