Engineering Optimization: Theory and Practice, Fourth Edition

(Martin Jones) #1

C Introduction to MATLAB


MATLAB, derived from MATrix LABoratory, is a software package that was originally
developed in the late 1970s for the solution of scientific and engineering problems. The
software can be used to execute a single statement or a list of statements, called a script
or m-file. MATLAB family includes the Optimization Toolbox, which is a library of
programs or m-files to solve different types of optimization problems. Some basic
features of MATLAB are summarized in this appendix.

C.1 Features and Special Characters


Some of the important features and special characters used in MATLAB are indicated
below:


  1. Symbol≫ This is the defaultpromptsymbol in MATLAB

  2. Symbol ; A semicolon at the end of a lineavoids the echoingthe
    information entered before the semicolon

  3. Symbol... Three periods at the end of a line indicates thecontinuationof
    the code in the next line

  4. help commandname This displays information on different ways the command can
    be used

  5. Symbol % Any text after this symbol is considered acommentand will
    not be operational

  6. MATLAB is case sensitive. Uppercase and lowercase letters are treated separately.

  7. MATLAB assumes all variables to be arrays. As such, separate dimension statements are
    not needed. Scalar quantities need not be given as arrays.

  8. Names of variables: variable names should start with a letter and can have a length
    of up to 31 characters in any combination of letters, digits, and
    underscores.

  9. The symbols for the basic arithmetic operations of addition, subtraction, multiplication,
    division, and exponentiation are+,−,∗, /, and∧, respectively.

  10. MATLAB has some built-in variable names and, as such, we should avoid using those
    names for variables in writing a MATLAB program or m-file. Examples of built-in names:
    pi (forπ), sin (for sine of an angle), etc.


Engineering Optimization: Theory and Practice, Fourth Edition Singiresu S. Rao 791
Copyright © 2009 by John Wiley & Sons, Inc.
Free download pdf