The following MATLAB code defines the differential equation describing a simple irreversible monomolecular reaction. Relevant examples in biological experiments are the decay of a radioactive tracer or a fluorescent probe. Also, in first approximation, an equation like this can describe the transition of an activated cellular receptor molecule to its inactive resting state. Save the function in a separate m.file, named decay.m, inside your MATLAB path.
function dydt = decay(t, y) % A->B k = 1; dydt = [-k*y(1) k*y(1)];
Now type the following instructions at the MATLAB command line to solve the system of differential equations (i.e. simulate the system behavior) and plot the results.
[t y] = ode45(@decay, [0 10], [5 1]); plot (t, y); legend ('[A]', '[B]');
Describing a reversible reaction of a single molecule is only slightly more complex. Now there are two rate constants, one for the forward and one for the backward reaction. Again, safe the function as an m.file, this time named isomerisation.m.
function dydt = isomerisation(t, y) % A <-> B k1 = 1; k2 = 0.5; dydt = [-k1*y(1)+k2*y(2) % d[A]/dt k1*y(1)-k2*y(2) % d[B]/dt ];
Simulate and plot the results as before, but referencing the isomerisation() function.
[t y] = ode45(@isomerisation, [0 10], [5 1]); plot (t, y); legend ('[A]', '[B]');