MATLAB: System of 2 differential equations

differential equationshomeworkMATLAB

I'm trying to express the following two differential equations in matlab in a form that will allow me to input them into a solver such as ode45. How would I input the following equations into matlab:
dC/dt = (-exp((-10/(T+273)))*C
dT/dt = 1000*(exp((-10)/(T+273))*C-10*(T-20)
where C and T are concentration and temperature (dependent variables) and t is time (independent variable).

Best Answer

The code you posted has errors, specifically unbalanced parentheses. I edited your equations to correct this, however I am not absolutely certain that my changes produce the correct result.
Try this:
% % % MAPPING: y(1) = C, y(2) = T
CTfcn = @(t,y) [-exp(-10/(y(2)+273))*y(1); 1000*(exp(-10/(y(2)+273))*y(1)-10*(y(2)-20))];
tv = linspace(0, 1E-3);
ic = [0, 0];
[T,Y] = ode45(CTfcn, tv, ic);
figure
plot(T,Y)
grid
legend('C', 'T')
The first row of ‘CTfcn’ is ‘C’, the second is ‘T’.
I also do not know what the initial conditions should be. I use [0,0] here, however they do not appear to have a significant effect on the ‘T’ result, regardless what their values are. Please provide the correct initial conditions, and please check to be certain your equations are correct as posted, and as I coded them.