Q1 How do I set the random number generator seed?
Use the command:
rndseed (timer);
Q2 How do I output data to a file?
The following code will generate a matlab formated matrix to a file.
f = createfile ("c:\\data.txt");
f.write ("m = [");
for i = 1 to rows (m) do
begin
for j = 1 to columns (m) do
f.write (m[i,j]);
f.write (";\n");
end;
f.write ("]\n");
f.close;
Q3 How do I make multiple plots on one graph?
Plotting is accomplished by the graph (m) command, where m is matrix. To plot multiple graphs, use the setghold (true) command to prevent the previous graph from being erased. Use setghold (false) to release the hold.
graph (m1); // Plot the data in matrix m1
setghold (true); // Hold the graph (i.e do not erase)
graph (m2); // Plot matrix m2 and overlay on previous graph
setghold(false); // Release the hold
Q4 How do I run a stochastic simulation?
// This will run multiple Gillespie simulations
// at different parameter values and plot the
// resulting runs on one graph.
P = defn myModel
$Xo -> S1; k1*Xo;
S1 -> $X1; k2*S1;
end;
p.Xo = 10;
p.S1 = 0;
p.X1 = 0;
p.k1 = 0.23; p.k2 = 0.56;
// Load the model into the Gillespie solver
gillLoadSBML (p.xml);
// Run a simulation and plot the results
m = gillSimulate (0, 50, 1);
graph (m);
// Hold the current graph, ie do not erase next time we plot
setghold (true);
// Loop over a set of parameter value and carry out a simulation
// Each time plot the results on the held graph.
k1 = 0.1;
for i = 1 to 5 do
begin
gillSetParameter ("k1", k1);
m = gillSimulate (0, 50, 1);
graph (m);
k1 = k1 + 2;
end;
// Release the graph hold
setghold (false);