function HW1Q3clear;clc;t0 = 0;tf = 30;C0= [0 50]; soln = ode45(@f, [t0 tf], C0);t=linspace(0,tf,100);C1=deval(soln,t,1);C2=deval(soln,t,2);plot(t,C1,'-k',t,C2,'-r','LineWidth',2);xlabel('t');ylabel('C');grid on;title('HW1, Q3')endfunction dCdt = f(t,C)V = 2; q = 0.4;Ci= 50;dCdt(1) = -(q/V)*C(1);dCdt(2) = (q/V)*(Ci-C(2));dCdt = dCdt';end
MATLAB: I have a homework assignment that I’m not sure how to do, the professor did not teach us anything about the matlab ode45 function. I have the line of code that I have so far but I’m not sure whats wrong.
ode45
Best Answer