Thread Subject: find misspelled variables in my m-file

Subject: find misspelled variables in my m-file

From: Carlos Adrian Vargas Aguilera

Date: 30 Oct, 2009 16:50:18

Message: 1 of 3

With the following shortcut in MATLAB 2008B I can easily get any error message (M-LINT) in my current m-file (without saving it first):

% Start---
% Define the handle for the set of java commands:
desktopHandle=com.mathworks.mlservices.MatlabDesktopServices.getDesktop;
% Determine the last selected document in the editor:
lastDocument=desktopHandle.getLastDocumentSelectedInGroup('Editor');
% Strip off the '*' which indicates that it has been modified.
CurrentFileName=strtok(char(desktopHandle.getTitle(lastDocument)),'*');
% Clears Command Window:
clc
% M-LINT:
mlint(CurrentFileName)
% ... End

Is there any similar way to look for misspelled variables (undefined) or functions in my current m-file? I know the Dependency Report does the job but I would like the result in the command window.

By the way, as I said, the previous shortcut does not saves first the current file. How could I do that?

Thank you, Carlos

Subject: find misspelled variables in my m-file

From: Carlos Adrian Vargas Aguilera

Date: 30 Oct, 2009 17:59:06

Message: 2 of 3

I've just found how to get the dependency functions of current m-file (but not misspelled variables or functions):

% Start---
% Define the handle for the set of java commands:
desktopHandle=com.mathworks.mlservices.MatlabDesktopServices.getDesktop;
% Determine the last selected document in the editor:
lastDocument=desktopHandle.getLastDocumentSelectedInGroup('Editor');
% Strip off the '*' which indicates that it has been modified.
CurrentFileName=strtok(char(desktopHandle.getTitle(lastDocument)),'*');
% Clears Command Window:
clc
% DEPFUN:
list = depfun(CurrentFileName,'-toponly','-quiet');
% Ignores MATLAB functions:
list(cellfun(@(x)strncmp(x,matlabroot,length(matlabroot)),list))=[];
% Display:
for k=1:length(list), disp(list{k}), end
% ... End

carlos

Subject: find misspelled variables in my m-file

From: Carlos Adrian Vargas Aguilera

Date: 30 Oct, 2009 19:04:01

Message: 3 of 3

Ok, I just find the function FARG by Clark (Us) Kent:

http://www.mathworks.com/matlabcentral/fileexchange/17291-fdep-a-pedestrian-function-dependencies-finder

carlos

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
farg Carlos Adrian Vargas Aguilera 30 Oct, 2009 15:09:05
depfun Carlos Adrian Vargas Aguilera 30 Oct, 2009 13:59:09
edit Carlos Adrian Vargas Aguilera 30 Oct, 2009 12:54:04
mfile Carlos Adrian Vargas Aguilera 30 Oct, 2009 12:54:04
dependency report Carlos Adrian Vargas Aguilera 30 Oct, 2009 12:54:04
mlint Carlos Adrian Vargas Aguilera 30 Oct, 2009 12:54:04
rssFeed for this Thread

Contact us at files@mathworks.com