* If you are running a long simulation, use screen first and start
the matlab
session from within. You can then detach the screen session, keeping
the
simulation running but allowing you to log out. You cannot use
graphics from
within screen, so you should write the script to save the data to file
instead,
and then plot it later.
* If you know in advance how large of an array (matrix) of data
will be, start
out by generating an array of that size (initialiazed to zero?) instead
of
growing the array during the simulation. This will prevent your
simulation
from having to sit idle while matlab and the operating system get more
memory.
Growing an array dynamically during the simulation can easily slow
down the
simulation by an order of magnitude when the needed memory is under
100 MB, and
can slow it even further (or stop it all together) if larger.
* If you need to save large amounts of data, but do not need all of
it to
perform the individual step of the simulations, you may want to use
a static
sized matrix, and periodically save the data to a file. This
will have the
aadded benefit of allowing you to contiune a simulation that may have
died
during the execution simply by loading the last data and picking up
where it
left off.
* If you have a section of code that is executed often, compile the
code into a
binary form using the mcc compiler.
NOTE: Using these techniques I have been able to speed up some
of my
simulations by a factor of 30.
I have some suggestions that may help future ECE 417 students.
When I took the class, the homework included several problems
that required us to run dozens of Matlab simulations to examine
different situations. Working with Eric Schuchard and with some
expert advice from Jim Melody, we came up with a system using
Matlab and LaTeX to efficiently run the simulations and report
the results. I'll outline the basic approach and include some
example files to help get you started.
The basic idea is to use Matlab to run the simulations, print the
resulting plots in a postscript format, and simultaneously write
most of the LaTeX file to generate a report. The advantage of
using Matlab to write the LaTeX file is that you can include
captions that completely describe the conditions used to generate
each figure. Once you practice with this approach, you can use
it to generate a relatively compact report. Since you can
include descriptive captions for each plot, it makes it easier
for the professor to examine your work and for you to comment on
the results. You have to know Matlab and be comfortable with
LaTeX to get this approach to work, but it is worth the initial
effort and will save you a lot of time in the long run.
I've attached five example files as a starter's kit. WARNING:
I
have not checked these files since I used then, so they may
contain some errors. Even with errors, they give you the general
idea and some of the specifics of what you have to do. Here's
a
brief description of the files:
prob16_a_1.m is the basic Matlab file used
to solve the homework
problem, generate and print the plots, and write the LaTeX file.
It will contain one or more loops to vary the parameters in the
problem. It calls prob16_print.m
to print the plots and
tex_fig_print.m to write the LaTeX commands.
prob16_print.m generates the plots for the simulation.
tex_fig_print.m writes the LaTeX file commands for each figure
and its caption. Since the command is called once for each
simulation, you can include the parameter values in the caption.
report1.tex is a partial LaTeX file used to
generate the report.
We used 10pt, two column format to save paper.
report1.ps.gz is an example of the final product.
You will have to modify the files to solve your homework
problems, but this should give you a good start. The approach
should be helpful for any class where you have to run many
simulations and report on the results. If you choose to use this
approach, the only request I have is that in your homework report
you cite Eric Schuchard, Jim Melody and Greg Toussaint as the
source for the software template.