Page 57 - Basics of MATLAB and Beyond
P. 57

File Opening and Closing: fclose fopen
                                           Unformatted I/O:       fread   fwrite
                                           Formatted I/O:         fgetl   fprintf
                                                                  fgets   fscanf
                                           File Positioning:      feof    fseek
                                                                  ferror ftell
                                                                  frewind
                                           String Conversion:     sprintf sscanf

                               10    Directories

                               When you type a string of characters, say asdf at the matlab prompt
                               and press return, matlab goes through the following sequence to try to
                               make sense of what you typed:

                                 1. Look for a variable called asdf;
                                 2. Look for a built in matlab function called asdf;

                                 3. Look in the current directory for an m-file called asdf.m;
                                 4. Look in the directories specified by the matlab search path for an
                                    m-file called asdf.m.
                               The following commands are useful for working with different directories
                               in matlab:
                                     cd        Change to another directory
                                     pwd       Display (print) current working directory
                                     dir       Display contents of current working directory
                                     what      Display matlab-relevant files
                                               in current working directory
                                     which     Display directory containing specified function
                                     type      Display file in the matlab window
                                     path      Display or change the search path
                                     addpath   Add directory to the search path
                                     rmpath    Remove directory from the search path

                               If the directory name contains a blank space, enclose it in single quotes:
                               dir ’my documents’

                               (On PCs or Macintoshes you can use the Path Browser GUI to manipu-
                               late the path. Select ’File’→’Set Path’ or click the Path Browser button
                               on the tool bar.)








                               c   2000 by CRC Press LLC
   52   53   54   55   56   57   58   59   60   61   62