Managing Your MATLAB M-Files

While using MATLAB one frequently wishes to create or edit an M-file and then return to MATLAB. One wishes to keep MATLAB active while editing a file since otherwise all variables would be lost upon exiting.

This can be easily done using the ! feature. If, while in MATLAB, you precede any system command -- such as those for editing, printing, or copying a file -- with an !, you can execute that command without exiting MATLAB. If, for example, the system command ed accesses your editor, the MATLAB command

        >> ! ed rotate.m

will let you edit the file named rotate.m using your local editor. Upon leaving the editor, you will be returned to wherever you left off in MATLAB.

If these processes can be run in multiple windows, as on a Sun workstation, you will want to keep MATLAB active in one window and your editor active in another.

When in MATLAB, the command

 
        dir

will list the contents of the current directory, while the command

 
        what

will list only the M-files in the directory.

You can use the MATLAB commands delete and type, respectively, to delete a diskfile and print a file to the screen; chdir to change the working directory. Please note that while these commands may reflect system commands, they avoid the use of an !.


Other Matlab Hints

Click on an item listed below to access additional MATLAB-related hints.


Return to ACS home page.


Please send comments and suggestions to

consult@rpi.edu