CHAPTER 1

Introduction to MATLAB


1.1 Discussion

Before you can start using MATLAB on Owlnet, you must learn how to use the UNIX operating system and the X-windows environment now used on all of the workstations on our network. These topics are discussed in some detail in the Notes on the Owlnet System prepared for you by Information System's at Rice. You will also need to find how to use the aXe (or another) editor before you get very far into the course. The aXe editor is very simple, but it requires some initial help in understanding the use of the multitude of menus used to control editing. Several other editors are available, but the GNUEMACS and vi are the ones that you will find most supported at Rice.

You should be familiar with enough Unix to use a workstation reasonably well. MATLAB can be executed directly from a Unix prompt such as you might see when you login through a dumb terminal. Its graphics features can only be utilized on a workstation with multiple windows (such as X-windows) available for you to work in. Thus you are advised to read carefully topics on workstation use and the X window system in the Owlnet notes unless you already are experienced in the use of a Sun workstation.

A description of most of the commands and techniques for programming will be found in the PRO-MATLAB User's Guide. A Copy of the User's Guide should be found in each Owlnet Laboratory. These notes cover only a small number of these commands so if you wish to expand your use of MATLAB you should obtain or have access to one of the User's Guides. The main purpose of these notes is to describe techniques found to be useful in a variety of problems in introductory engineering courses. We have also collected a large number of problems that we hope will challenge you to learn even more techniques.

1.3 Links to Other Sites

There are many web sites that now provide tutorials and information about the use of Matlab. Here are a couple that lead to many more.


1.3 Use of help

There may be commands available on the Owlnet version of MATLAB that have been added since the PRO-MATLAB User's Guide was last updated. Some of these may be described and used in these notes. Other commands may be found by listing the currently available function names with HELP while you are in a MATLAB session. This may be done by use of the help in the Matlab Command Window or by us of the helpdesk or helpwin options. The helpdesk command should bring up a "Web browser" window where you can examine a number of Matlab topics. The Unix version of this for Matlab 5.1 looks like:

 

The helpwin command brings up the MATLAB Help Window that will enable you to get help on any Matlab function in your path. This window essentially does the same thing as help, thus you may find its use to parallel the following discussion. The command help by itself gives a list of HELP topics. If you type:

>>  help  <-- asking for help
   

you will then see a list of different primary help topics, which are mostly just directories of MATLAB functions. By typing help topic name, you get a listing of the specific functions in that topic. For example:

>>  help ceng301/matlab
 
          Directories in /home/ceng301/matlab
 
  Directory       Contains
  chemeq     Chemical Equilibrium Functions
  datbas     Data Base programs
  fd3        Flow diagram functions: no longer supported in 1996.
  engmods    Mass and Energy balance Modules
  humid      Humidity programs
  misc       Special programs used as examples in the notes
  massmods   Mass balance modules.
  omods      Old modular and support programs no longer needed or 
             supported in 1996.  These are not automatically accessed. 
  pichelps   Programs that show pictures of the units
  specmods   Special modular functions 
  utilities  Functions used by many of the modular programs
  vle        Vapor liquid equilibria functions 

You should type:

>>  help dirname

to get a listing of the files in the directory by the name: dirname You can then get a listing of the programs in each directory by following the
suggestion:

>>  help pichelps
 
 
  Visual aid for matlab functions
 
  picfraco.m    - Goes to section in Chapter 5, cengnotes, that shows fraco.m
  picmix.m      - Goes to section in Chapter 5, cengnotes, that shows mix.m
  picmixe.m     - Goes to section in Chapter 5, cengnotes, that shows mixe.m
  picphaseg.m   - Goes to section in Chapter 5, cengnotes, that shows phaseg.m
  picreact.m    - Goes to section in Chapter 5, cengnotes, that shows react.m
  picreacte.m   - Goes to section in Chapter 5, cengnotes, that shows reactee.m
  picreacten.m  - Goes to section in Chapter 5, cengnotes, that shows reacten.m
  picreactr.m   - Goes to section in Chapter 5, cengnotes, that shows reactr.m
  picsep.m      - Goes to section in Chapter 5, cengnotes, that shows sep.m
  picsepe.m     - Goes to section in Chapter 5, cengnotes, that shows sepe.m
  picsept.m     - Goes to section in Chapter 5, cengnotes, that shows sept.m
  picsplit.m    - Goes to section in Chapter 5, cengnotes, that shows split.m
  picsplite.m   - Goes to section in Chapter 5, cengnotes, that shows splite.m


These are all specific functions which can be called in MATLAB. By typing:

>>  help function name 


you can get a detailed description of a function in MATLAB if it includes such a description in its heading. For example:

>> help picsep
 
  function picsep
  This displays a picture illustrating use of the command SEP.
  Note that this will only run in Matlab versions that support the WEB
  command (Matlab 5.0 and above).  Otherwise, visit the following web site:
  http://www.owlnet.rice.edu/~ceng301/5.html#5.1
 
  Example: >> sep([0.2 0.3 0.8 0.5],1,[2 3])
    This example separates stream 1 (which contains 4 compounds: a,b,c,d)
    into exit streams 2 and 3.
    Stream 2 is the first outlet stream because it is the first stream
    specified in the vector: out (3rd argument of sep), and will get:
                        20% of cmpd a in Stream 1
                        30% of cmpd b in Stream 1
                        80% of cmpd c in Stream 1
                        50% of cmpd d in Stream 1
    Stream 3 is the other outlet stream and would get the remaining
    amounts of the cmpds.
 
    NOTE:  the sum of the t vector does NOT necessarily equal one! 
 
  Comments/Picture: TYLC, ACP
  Comments/Picture/Program: ADD
  Last updated:  August, 1997
 

Several problems assigned in this course will ask you to investigate functions that may be found in several directories. You should use help on the functions first to see what instructions are given about the functions and then you should list the function if you need more information.

The functions that have been developed for Ceng 301 have comments in them that should give you a lot of information about how to use them. If these comments are not clear please let the instructor know so that they can be further explained. When you type help, followed by a command name, you get a listing of comments at the beginning of the function.

In addition to giving you a way to find out about functions that are not described in these notes or in the User's Guide, the help, command will frequently show you new ways to use functions. Both the developers of MATLAB and the authors of functions for your courses frequently expand the scope of functions to make them more useful. The comments in the functions are nearly always updated to reflect these changes. It may take a semester for these notes to be updated and it may take over a year for the User's Guide. Even then some of the new features may escape the updating of the texts.


Continue on to Chapter 2
Return to Table of Contents