23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Techniques for Improving Performance<br />

Overloading Built-In Functions<br />

Overloading <strong>MATLAB</strong> built-in functions on any of the standard <strong>MATLAB</strong><br />

data types can negatively affect performance. For example, if you overload<br />

the plus function tohandleanyoftheintegerdatatypesdifferently,youmay<br />

hinder certain optimizations in the <strong>MATLAB</strong> built-in function code for plus,<br />

and thus may slow down any programs that make use of this overload.<br />

Functions Are Generally Faster Than Scripts<br />

Your code executes more quickly if it is implemented in a function rather<br />

than a script.<br />

Load and Save Are Faster Than File I/O Functions<br />

If you have a choice of whether to use load and save instead of the low-level<br />

<strong>MATLAB</strong> file I/O routines such as fread and fwrite, choose the former.<br />

load and save have been optimized to run faster and reduce memory<br />

fragmentation.<br />

Avoid Large Background Processes<br />

Avoid running largeprocessesinthebackgroundatthesametimeyouare<br />

executing your program in <strong>MATLAB</strong>. This frees more CPU time for your<br />

<strong>MATLAB</strong> session.<br />

11-11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!