Engineering Optimization: Theory and Practice, Fourth Edition

(Martin Jones) #1
C.4 Optimization Toolbox 793

(ii) To generate all numbers between 0 andπin increments ofπ/ 6

> >0 :pi/6 :pi

This command generates the numbers
0 0.5236 1.0472 1.5708 2.0944 2.6180 3.1416

C.3 CREATING m-FILES


MATLAB can be used in an interactive mode by typing each command from the
keyboard. In this mode, MATLAB performs the operations much like an extended cal-
culator. However, there are situations in which this mode of operation is inefficient.
For example, if the same set of commands is to be repeated a number of times with dif-
ferent values of the input parameters, developing a MATLAB program will be quicker
and efficient.
A MATLAB program consists of a sequence of MATLAB instructions written
outside MATLAB and then executed in MATLAB as a single block of commands.
Such a program is called a script file, or m-file. It is necessary to give a name to the
script file. The name should end with.m(a dot followed by the letterm). A typical
m-file (calledfibo.m) is

file “fibo.m“

% m-file to compute Fibonacci numbers
f=[1 1];
i=1;
while f(i)+f(i+1)<1000
f(i+2)=f(i)+f(i+1);
i=i+1;
end

C.4 Optimization Toolbox


The Optimization Toolbox includes programs or m-files that can be used to solve
different types of optimization problems. The following publication gives information
on the optimization toolbox, including algorithms and examples for different programs:

T. F. Coleman, M. A. Branch, and A. Grace,Optimization Toolbox —for Use with
MATLAB, User’s Guide, Version 2, Math Works, Inc., Natick, MA, 1999.

The use of any program or m-file in the optimization toolbox requires the following:


  • Selecting the appropriate program or m-file to solve the specific problem at hand.

  • Formulation of the optimization problem in the format expected by MATLAB. In
    general, this involves stating the objective function in a specific form such as a
    “minimization” type and the constraints in a specific form such as “less than or
    equal to zero” type.

Free download pdf