23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12 <strong>Programming</strong> Tips<br />

For M-file functions, case requirements depend on the case sensitivity of the<br />

operating system you are using. As a rule, naming and calling functions using<br />

lowercase generally makes your M-files more portable from one operating<br />

system to another.<br />

Getting a Function’s Name and Path<br />

To obtain the name of an M-file that is currently being executed, use the<br />

following function in your M-file code.<br />

mfilename<br />

To include the path along with the M-file name, use<br />

mfilename('fullpath')<br />

For more information: See the mfilename function reference page.<br />

WhatM-FilesDoesaFunctionUse?<br />

For a simple display of all M-files referenced by a particular function, follow<br />

the steps below:<br />

1 Type clear functions to clear all functions from memory (see Note below).<br />

2 Execute the function you want to check. Note that the function arguments<br />

youchoosetouseinthisstepareimportant,sinceyoucangetdifferent<br />

results when calling the same function with different arguments.<br />

3 Type inmem to display all M-Files that were used when the function ran. If<br />

you want to see what MEX-files were used as well, specify an additional<br />

output, as shown here:<br />

[mfiles, mexfiles] = inmem<br />

Note clear functions does not clear functions locked by mlock. Ifyou<br />

have locked functions, (which you can check using inmem), unlock them with<br />

munlock, and then repeat step 1.<br />

12-14

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

Saved successfully!

Ooh no, something went wrong!