Im trying to write a code and graph it but i keep getting these following errors:
Error using odearguments (line 87)
The entries in tspan must strictly increase or decrease.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in SEMIBATCH_6_6graph (line 3)
[v,x]=ode45('SEMIBATCH_6_6',vspan,ic);
Im a bit new to Matlab and am slowly but surely figuring this all out.
% xdot(1)=dV/d(t)
% xdot(2)=d(Nc)/d(t)
% xdot(3)=d(Nb)/d(t)
% xdot(4)=d(Na)/d(t)
function xdot=SEMIBATCH_6_6(v,x)Cbo = 1.5;Fbo = 6;Cao = 0.75;Nao = 1125;k = 5.1;rho =1000;MWCO2 = 44;Cc=Nc/V;X = (Nao-Na)/Nao;Ca = Na/V;Cb = Nb/V;ra = -k*Ca*Cb;vo = Fbo/Cbo;FCO2 = -ra*V;vCO2 = FCO2*MWCO2/rho;Cd = Cc;xdot(1,:) = vo-vCO2;xdot(2,:) = -ra*V;xdot(3,:) = Fbo+ra*V;xdot(4,:) = ra*V;end
Here is the code for the graphing. Any little bit helps
ic=[1125; 0; 0];vspan= [1500, 1500, 2450.5, 2450.5];[v,x]=ode45('SEMIBATCH_6_6',vspan,ic);plot(v,x);title('Semibatch with Moles as the Variables');xlabel('V(Seconds)');ylabel('Na,Nb,Nc');ic=[.75; 0; 0];xspan=[0,0,1,1];[v,x]=ode45('SEMIBATCH_6_6',xspan,ic);plot(v,x);title('Semibatch with Moles as the Variables');xlabel('V(Seconds)');ylabel('Ca,Cb,Cc');
Best Answer