Graphics Programs Reference
In-Depth Information
directory to the path or change the working directory. The potential disadvan-
tage of this approach is that you must be careful when naming files. When
MATLAB searches for files, it uses the first file with the correct name that it
finds in the path list, starting with the current working directory. If you use
the same name for different files in different directories in your path, you can
run into problems.
You can also control the MATLAB search path from the Path Browser.
To open the Path Browser, type editpath or pathtool , or select File : Set
Path... . The Path Browser consists of a panel, with a list of directories in the
current path, and several buttons. To add a directory to the path list, click
on Add Folder... or Add with Subfolders... , depending on whether or not
you want subdirectories to be included as well. To remove a directory, click on
Remove . The buttons Move Up and Move Down can be used to reorder the
directoriesinthepath.NotethatyoucanusetheCurrentDirectorybrowserto
examine the files in the working directory, and even to create subdirectories,
move M-files around, etc.
The information displayed in the main areas of the Path Browser can also be
obtained from the command line. To see the current working directory, type
pwd . To list the files in the working directory type either ls or dir .Tosee
the current path list that MATLAB will search for files, type path .
If you have many toolboxes installed, path searches can be slow, especially
with lookfor . Removing the toolboxes you are not currently using from the
MATLAB pathis one way to speed up execution.
Using the Command Window
We have already described in Chapters 1 and 2 how to enter commands in the
MATLAB Command Window. We continue that description here, presenting
an example that will serve as an introduction to our discussion of M-files.
Suppose you want to calculate the values of
sin(0 . 1) / 0 . 1 , sin(0 . 01) / 0 . 01 , and sin(0 . 001) / 0 . 001
to 15 digits. Sucha simple problem can be worked directly in the Command
Window. Here is a typical first try at a solution, together with the response
that MATLAB displays in the Command Window:
>> x = [0.1, 0.01, 0.001];
>> y = sin(x)./x
Search WWH ::




Custom Search