MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Identify Program Dependencies


If you need to know what other functions and scripts your program is dependent upon,
use one of the techniques described below.

Simple Display of Program File Dependencies


For a simple display of all program files referenced by a particular function, follow these
steps:

1 Type clear functions to clear all functions from memory (see Note below).

Noteclear functions does not clear functions locked by mlock. If you have
locked functions (which you can check using inmem) unlock them with munlock, and
then repeat step 1.
2 Execute the function you want to check. Note that the function arguments you choose
to use in this step are important, because you can get different results when calling
the same function with different arguments.
3 Type inmem to display all program files that were used when the function ran. If you
want to see what MEX-files were used as well, specify an additional output:

[mfiles, mexfiles] = inmem

Detailed Display of Program File Dependencies


For a more detailed display of dependent function information, use the
matlab.codetools.requiredFilesAndProducts function. In addition to program
files, matlab.codetools.requiredFilesAndProducts shows which MathWorks
products a particular function depends on. If you have a function, myFun, that calls to the
edge function in the Image Processing Toolbox™:

[fList,pList] = matlab.codetools.requiredFilesAndProducts('myFun.m');
fList

fList =

'C:\work\myFun.m'

The only required program file, is the function file itself, myFun.

25 Programming Utilities

Free download pdf