|
|
|
Part 11: Using MATLAB with the CCP Modules MATLAB m-files designed for use in conjunction with the Connected Curriculum
Project modules are available for downloading to your computer.
MATLAB Tutor
When you click
on the MATLAB icon that appears on the table-of-contents page of a module, you
will get instructions about how to download a "package" of m-files that
are coordinated with the module. For example, for the module named Numerical Solutions
of Differential Equations,
there are eight m-files in the package, namely, numdiff1.m through numdiff5.m,
dfun.m, slpfield.m, and compmap.m.
|
After you have downloaded and uncompressed the package of m-files, then to use the instructions in the file numdiff1.m, for example, all you have to do is type: numdiff1 at the MATLAB prompt and press Enter. The instructions will appear in your MATLAB window. That assumes, of course, that MATLAB knows which file on your computer system contains numdiff1.m.
There are two ways that you can tell MATLAB where to find the numdiff1.m file. You can either (1) make sure the file is in your working directory, or (2) add the name of the file that contains numdiff1.m to MATLAB’s search path.
You can make sure you are in the directory containing the m-files you need before
you even start-up your MATLAB session. You can also change your working directory
while you are in MATLAB as we now demonstrate.
You can navigate through your directories to find
the one containing numdiff1.m by using the "cd" command (which stands
for "change directory").
An alternative way to tell MATLAB where to find your m-files, especially if they are in two different directories, is to add the directory or directories containing these m-files to the search path.
You can add the directories mydir1, mydir2, etc. to the old path with the command: addpath mydir1 mydir2 etc.
Unfortunately, when you quit your current MATLAB session, your additions to the path are "forgotten." If you always start your new MATLAB sessions from the same working directory, you can use your text editor to create an m-file titled startup.m in that directory which MATLAB automatically executes when it starts. In that m-file, put the line addpath mydir1 mydir2 etc.
In MATLAB, if you know the name of a command, you can get information about it by entering: help command_name at a prompt. If you enter: help path or help addpath you will find more detailed instructions on the use of these commands as well as examples of adding file names to paths for a variety of computer systems including Unix, Windows/DOS, and Macintosh.
|
|
|
modules at math.duke.edu | Copyright CCP and the author(s), 2000 |