Ordinary differential equations with two unknows (ode45)
Show older comments
Hi, thank you very much for any help!
I am trying to solve two equations by converting them into two ordinary differential equations, but ODE45, ODE23, et al. cannot solve them well.
The two unknows vv and ff are a function of time t. The code is listed as below:
p.a=0.0062; p.b=0.0128; p.L=17.5e-6; p.Vo=1e-6; p.Vl=5e-7; p.sigma=5e7; p.k=0.95*p.sigma*(p.b-p.a)/p.L;
odefun=@(t,y) ode_isothermal(p,t,y);
yo=zeros(2,1);
yo(1) = p.L/p.Vo; % initial state variable
yo(2) = p.Vo; % initial velocity
tic % four/fifth order Runge-Kutta solver
options=odeset('Refine',1,'RelTol',1e-6,'InitialStep',1e-5,'MaxStep',1e5);
[t,y]=ode45(odefun,[0 2000],yo,options);
toc
figure(1); % figure
plot(t,log(y(:,2)/p.Vo));
ylabel('ln(V/V_{0})');xlable('Time');
box on; set(gca,'xlim',[0 2000])
%function
function dydt=ode_isothermal(p,~,y)
dydt=zeros(2,1);
ff=y(1);
vv=y(2);
dydt(1)=1-ff*vv/p.L; % function 1 for ff
kv=p.k*(p.Vl-vv);
bb=p.b*(dydt(1)/ff)*(p.Vl/vv).^(1/3);
aa=p.b/3/vv*(p.Vl/vv).^(1/3).*log(ff/35);
dydt(2)=(kv-bb)/(p.a/vv+0.1-aa); %function 2 for vv
end
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

