list MATLAB built-in function calls

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
afinch
Posts: 6
Joined: Thu Jan 20, 2005 8:01 pm

list MATLAB built-in function calls

Post by afinch »

Hello, I'm not savvy with syntax files but there probably is a simple way to make a macro that lists all the MATLAB built-in commands of a source file. I need to make a list of all the function calls used by a large set of MATLAB source files as a preliminary step to converting the code into other languages. So if I could make a macro that generates a list to an output file I could open the files one-by-one and append the lists into a spreadsheet. Then I'd sort the list and delete the duplicates manually to obtain a single set of function calls that need to be implemented. Can anyone tell me how this could be done? :?:
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

I suspect it's possible but lacking knowledge of matlab will be a hinderance. Perhaps a snippet of a source file to show what it looks like in the raw format and then ticking off the functions defined in there would get me going (unless other people have dealt with it and know what to do).

Would you want to make a syntax file per source file or just generate a single syntax file of all possible functions?
I choose to fight with a sack of angry cats.
afinch
Posts: 6
Joined: Thu Jan 20, 2005 8:01 pm

Post by afinch »

Actually I'm not sure how to accomplish what I'd like. A MATLAB syntax file exists. I got it from the TextPad website. When TP opens a file it parses all the words and symbols and compares them to the keywords of the syntax file. My question: Is there some way to tweek that parsing process so that when TP opens the file and starts parsing it copies all the keywords it finds into an output file? Maybe a macro could be written that enables/disables that feature automatically. Or maybe this is too much "pie-in-the-sky" for TP and I'll just have to use another utility. I could write a C program that uses a subset of the MATLAB syntax file (the list of keywords) and duplicate the parsing to the degree needed to find the keywords of the source file. Then output those strings to a file. Then I could hook-in a TP macro to call the C executable on the displayed source file. But I was hoping there'd be an easier way... :?
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

That was something along the idea of what I was going to suggest/write although I'd probably use Python to chew up the files.
I choose to fight with a sack of angry cats.
dixonc
Posts: 54
Joined: Mon Feb 02, 2004 3:05 pm

Post by dixonc »

Could you not just use the profile command in MATLAB? This profiles your script / function and lists all the function calls, how long they take etc.
afinch
Posts: 6
Joined: Thu Jan 20, 2005 8:01 pm

Post by afinch »

The MATLAB 'profile' command (or the 'depfun' command) wouldn't fit this purpose for a few reasons, the most prominent being it would list ALL functions and not just the buitin functions of MATLAB. Plus it appears that you'd have to run the scripts which is something I wouldn't want to do due to the complexity of this project and its dependent applications. I just want to open the MATLAB source files in an editor, "push a button" and get a simple list. Ideally I'd like to open ALL the files in the editor and push a button and retrieve a single list for the whole set! But one step at a time. I'm building a C routine to do simple parsing and compares. When that's done I think I'll check out WildEdit's capabilities for repeating the action on a set of files.
Thanks for all the help, people. It's appreciated. :)
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

TextPad limits a search expression to about 1024 characters, but in WildEdit you can search using the regular expression

Code: Select all

\<(abs|accumarray|acos|acosd|acosh|acot|...|zoom)\>
but this gets seriously slow when the search expression contains 1000 alternatives and 9000 characters.

Is there a reasonably-sized subset of all the functions that will do?

I know absolutely nothing about MATLAB. I got the list from the MathWorks site.

But really this is a job for a scripting language: Perl, Python, Ruby, or what you will.
afinch
Posts: 6
Joined: Thu Jan 20, 2005 8:01 pm

Post by afinch »

The MATLAB set of builtin commands according to the syntax file I got from TP is about 700. So I'm not sure if that kind of search command (WildEdit expression) would be desirable. But it is something worth considering.
I haven't had time to check out WildEdit. Does it have a similar capability as TextPad for running an executable? Meaning its easy enough to create a TP macro to run an executable using the currently displayed file as an input parameter. What I'm wondering is if WildEdit can do the same thing but use ALL the filenames of the files opened within the editor as a single input parameter. This parameter could be one string containing the filenames separated by spaces. Of course there probably would be a limit on the length of the string... :?
Post Reply