Paths and Working Directories
Matlab has a working directory, just as a Unix shell does. (In fact, you can see the present working directory via the same command as in Unix: pwd. It also appears in the menu bar at the top of the Matlab workspace.) This will be the default location where files are saved. Similarly, Matlab has a path variable governing which directories are used when you try to run a command. The path is initialized to include all the standard Matlab commands plus additional toolboxes that may be available. You can change the path via the File menu. However, in the lab environment it is not possible to save a modified path for future use.
The working directory defaults to H:/MATLAB. You can change the working directory using cd, and can also create a new subdirectory using mkdir. However, every time you restart Matlab, the working directory will be reset to the default. To change this behavior, you will need to create a startup file.
The Startup File
If there are commands you wish to execute automatically every time Matlab is started up, you should put them in a file named startup.m located in the default directory (i.e., your top-level H: drive). A typical startup file might contain several commands, like this:
addpath N:/COURSES/CSC/CSC370 format compact dbstop if error cd H:/Matlab/CSC370
The first line adds a directory with files for this course. The second tells Matlab to reduce the amount of whitespace included in printouts. The third line tells Matlab to enter a debugging mode if it encounters an error. (If you plan to use this, you should read the help files on dbstop, dbstep, dbcont, dbup, dbdown, and dbquit.) The last line changes the working directory, and presumes that you have already created a directory at H:/Matlab/CSC370.
You may create the startup.m file using any text editor, including the one built into Matlab. (To open the editor, just click on the New M-File icon in the toolbar.)