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!