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.
Matlab Files for this Course
There is a network drive folder containing a selection of files that may be useful for some of the exercises. You can add it to your Matlab path to give access to the routines. On Windows, the folder should appear at O:\CSC\CSC370\Utility. On Mac, you will have to add it explicitly. From any Smith lab machine, select Go > Connect to Server and then enter: cifs://ad.smith.edu/files/academic/courses/CSC/CSC370 and look for the Utilities folder.
There are a few other folders on the same drive that we will most likely not need to use. One exception is the Images folder, containing some of the test images used in the exercises. (These are also accessible by downloading from the exercise's web page.)
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 O:\CSC\CSC370\Utility 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.)