# Solving Coupled System of ODEs in MATLAB

by math_guy314
Tags: differential eqs, matlab, ode, plot
 P: 145 Assuming your differential equations are all typed in correctly, your ODE function looks ready to solve. Theres a couple things that I notice though: At the command window you run: >> plot(t,f) but there is no variable t or f in the workspace. Should the t be T? Also where is the f coming from? you never create f in your main workspace. Should this be the code you are trying to run: %solution [T,Y]=ode15s(@carbon,[1000 3000],[1 2.01 2.23 2.2 2.26]); %graph subplot(2,1,1); t = T yr=[1000 1850 1950 1980 2000 2050 2080 2100 2120 2150 2225 2300 2400 2500 3000]; data=[0 0 1 4 5 8 10 10.5 10 8 3.5 2 0 0 0]; f=interp1(yr,data,t,'pchip'); plot(t,f) xlabel('Time, t', 'fontsize', 14) ylabel('Carbon Dioxide Release Rate, f(t)', 'fontsize', 14) subplot(2,1,2); plot(T,Y(:,1)); xlabel('Time, t', 'fontsize', 14) ylabel('Partial Pressure of Carbon Dioxide, p(t)', 'fontsize', 14)