1080 PDF ADDE

background image

0-8493-????-?/00/$0.00+$.50
© 2000 by CRC Press LLC

© 2001 by CRC Press LLC

Addendum: MATLAB 6

When I started developing this book’s material in 1997, the faculty and stu-
dents in the Electrical and Computer Engineering Department at the City
University of New York (CUNY), my home institution, were in the most envi-
able position of having access to up-to-date versions of MATLAB on all major
computer platforms at the university. Unfortunately, this state of bliss did not
last. MATLAB 6 releases are now available for the PC and UNIX™ platforms,
but not for the MAC™. Faced with this situation and the significant number
of instructional laboratories equipped with MAC computers, both on CUNY
campuses and in feeder institutions, and the large number of students own-
ing MAC computers, I opted to use in this text the syntax that is still common
to all platforms, i.e., not the latest. Fortunately, this was still possible because
MATLAB 6, Release 12, still accepts the obsolete commands, although newer
versions of these commands are now recommended.

As there is no guarantee that this backwards compatibility will continue in

future releases, in this addendum, I summarize only those modifications that
are of direct relevance to this text. Further details can be found in the
MATLAB manuals and the help files.

1. The function handle was added.

a. A function handle is a MATLAB data type that contains infor-

mation used in referencing a function. The function handle
stores all the information MATLAB needs to evaluate the func-
tion from any location in the MATLAB environment.

b. The

feval

function can be used with either function handles

or function name strings. Evaluation of function handles is pre-
ferred over evaluation of the function name.

2. Most names in MATLAB are now truncated after the 31st character,

i.e., MATLAB cannot, for example, distinguish between two names
with the same first 31 characters.

3. The following MATLAB functions have been renamed:

Old name

New Name

Description

fmin

fminbnd

Minimize a function of one variable

background image

© 2001 by CRC Press LLC

4. The ODE problem components that were passed to the

Solver

through an ODE file are now passed directly as arguments. The

Solver

is one of the ODE solver functions such as

ode23

,

ode45

,

etc. …

NOTE

The reader should not conclude from these limited syntax changes

that MATLAB 6 is only a cosmetic improvement over its previous version.
Nothing is further from the truth. In our most recent extensive nonlinear
optics computations, my colleague Irina Gladkova and I obtained, using
MATLAB 6, almost an order of magnitude improvement in execution time
and similar impressive improvements in memory management over previ-
ous versions’ performance.

In the following examples, we illustrate the use of some of the above:

Example Ad.1

Find the abscissa of the minimum of the function

y

= (

x

– 2)

2

+ 3 over the inter-

val [0 4].

Solution:

a.

Create a function M-file:

function y=ad1(x)

y=(x-2).^2+3;

b.

Call from the command window:

xmin=fminbnd(@ad1,0,4)

Example Ad.2

Find the coordinates and the value of the minimum of the function

near the point (1, 1).

Solution:

a.

Create a function M-file:

function y=ad2(x)

y=2*x(1)^2+4*x(1)*x(2)+3*x(2)^2;

b.

Call from the command window:

fmins

fminsearch

Minimize a function of several variables

quad8

quadl

Evaluate one dimensional integral

Old name

New Name

Description

y

x

=

+

2

1

2

x x

x

+

4

3

1 2

2

2

background image

© 2001 by CRC Press LLC

[xmin,ymin]=fminsearch(@ad2,[1,1])

Example Ad.3

Plot as a function of time the solution and its first derivative for the following
Van der Pole equation:

with the following initial conditions

y

(0) = 2 and

y

(0) = 0.

Solution:

a.

Reduce the above second-order ordinary differential equation to
two first-order equations.
Let:

y

1

=

y

and

y

2

=

y

,

The system of first order ODE is then:

b.

Create a function M-file:

function

yprime=vandpol(t,y)

yprime=[y(2);(1-y(1)^2)*y(2)-y(1)];

c.

Enter in the command window:

tspan=[0 30];

yinit=[2;0];

[t,y]=ode45(@vandpol,tspan,yinit);

plot(t,y(:,1),t,y(:,2))

′′ − −

′ + =

y

y y

y

(

)

,

1

0

2

′ =

′ = −

y

y

y

y y

y

1

2

2

1

2

2

1

1

(

)


Document Outline


Wyszukiwarka

Podobne podstrony:
1080 PDF C09
1080 PDF C07
1080 PDF C08
1080 PDF C10
1080 PDF C04
1080 PDF C06
1080 PDF C03
1080 PDF TOC
1080 PDF C01
1080 PDF C05
1080 PDF C02
1080 PDF REF
1080 PDF C09
1080 PDF C07
1080 PDF C08
instr 2011 pdf, Roztw Spektrofoto
(ebook PDF)Shannon A Mathematical Theory Of Communication RXK2WIS2ZEJTDZ75G7VI3OC6ZO2P57GO3E27QNQ
KSIĄŻKA OBIEKTU pdf
zsf w3 pdf

więcej podobnych podstron