Go to CCP Homepage Go to Materials Page Go to Engineering Mathematics Materials Go to Table of Contents
Go Back One Page Go Forward One Page

MATLAB Tutor

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.

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.


  1. Click on the MATLAB icon below and you will see the page of instructions for downloading and uncompressing the package of m-files for the Numerical Solutions of Differential Equations module. Go ahead and download the appropriate package file.

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.

  1. If you are in MATLAB, to find out what your working directory is, enter:

    pwd

  2. To see a list of all the files in your working directory, enter:

    dir

You can navigate through your directories to find the one containing numdiff1.m by using the "cd" command (which stands for "change directory").

  1. To go up one in the directory structure, enter:

    cd ..    %a space followed by two periods

  2. Pick the subdirectory you want to go to in the subdirectory list inside the directory. To go there, enter:

    cd sub_name    %change "sub_name"

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.

  1. To find out what MATLAB’s current search path is, enter:

    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.

Go to CCP Homepage Go to Materials Page Go to Engineering Mathematics Materials Go to Table of Contents
Go Back One Page Go Forward One Page


| CCP Home | Materials | Engineering Mathematics | Module Contents | Back |

modules at math.duke.edu Copyright CCP and the author(s), 2000