Code covered by the BSD License  

Highlights from
CHECKVARS

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 4.38 KB File ID: #27853
image thumbnail

CHECKVARS

by Matt Fig

 

08 Jun 2010 (Updated 10 Jun 2010)

Checks for function masking by variables in an M-File.

| Watch this File

File Information
Description

CHECKVARS(FILENAME) reads the M-File FILENAME and looks at all variables used inside. Then a check is made to see if any of these variables are possibly masking another function on the path. If conflicts are found, a description of each one is printed to the command window. [V,L] = CHECKVARS(FILENAME) also returns all variables V used in the file. L has the line number for each variable.

One fun thing is to do this:

D = dir([matlabroot,'\toolbox\matlab']);
p = pwd;

for jj = 3:length(D)
    try
        cd([matlabroot,'\toolbox\matlab\',D(jj).name]);
    catch
        continue
    end
    
    fprintf('\t\t\t In directory: %s\n',D(jj).name)
    M = dir('*.m');
    cd(p)

    for ii = 1:length(M)
        fprintf('%s\n',M(ii).name);
        checkvars(M(ii).name);
        fprintf('\n')
    end
end

This was written in response to a newsgroup thread.
See the help for more information and examples.

String manipulation has never been my strong suit, so if there are simplifications which could be made I would appreciate an email showing me where. Also, if a bug is found please email me to let me know about it. Thanks.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
10 Jun 2010 Matt Fig

It was brought to my attention that there are a few short-comings in the file. The file will be updated shortly.

Please login to add a comment or rating.
Updates
10 Jun 2010

Efficiencies added, help enhanced, func args utility expanded.

Tag Activity for this File
Tag Applied By Date/Time
masking Matt Fig 09 Jun 2010 10:28:03
mask Matt Fig 09 Jun 2010 10:28:03
variables Matt Fig 09 Jun 2010 10:28:03
function Matt Fig 09 Jun 2010 10:28:03

Contact us at files@mathworks.com