Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
19
Добавлен:
09.02.2015
Размер:
406.02 Кб
Скачать

matlab\funfun- Функции решения обычных дифференциальных уравнений

Optimization and root finding

<fminbnd> - Scalar bounded nonlinear function minimization.

FMINBND Single-variable bounded nonlinear function minimization.

X = FMINBND(FUN,x1,x2) attempts to find a local minimizer X of the function

FUN in the interval x1 < X < x2. FUN is a function handle. FUN accepts

scalar input X and returns a scalar function value F evaluated at X.

X = FMINBND(FUN,x1,x2,OPTIONS) minimizes with the default optimization

parameters replaced by values in the structure OPTIONS, created with

the OPTIMSET function. See OPTIMSET for details. FMINBND uses these

options: Display, TolX, MaxFunEval, MaxIter, FunValCheck, PlotFcns,

and OutputFcn.

X = FMINBND(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a

structure with the function FUN in PROBLEM.objective, the interval

in PROBLEM.x1 and PROBLEM.x2, the options structure in PROBLEM.options,

and solver name 'fminbnd' in PROBLEM.solver. The structure PROBLEM must

have all the fields.

[X,FVAL] = FMINBND(...) also returns the value of the objective function,

FVAL, computed in FUN, at X.

[X,FVAL,EXITFLAG] = FMINBND(...) also returns an EXITFLAG that describes

the exit condition of FMINBND. Possible values of EXITFLAG and the

corresponding exit conditions are

1 FMINBND converged with a solution X based on OPTIONS.TolX.

0 Maximum number of function evaluations or iterations reached.

-1 Algorithm terminated by the output function.

-2 Bounds are inconsistent (that is, ax > bx).

[X,FVAL,EXITFLAG,OUTPUT] = FMINBND(...) also returns a structure

OUTPUT with the number of iterations taken in OUTPUT.iterations, the

number of function evaluations in OUTPUT.funcCount, the algorithm name

in OUTPUT.algorithm, and the exit message in OUTPUT.message.

Examples

FUN can be specified using @:

X = fminbnd(@cos,3,4)

computes pi to a few decimal places and gives a message upon termination.

[X,FVAL,EXITFLAG] = fminbnd(@cos,3,4,optimset('TolX',1e-12,'Display','off'))

computes pi to about 12 decimal places, suppresses output, returns the

function value at x, and returns an EXITFLAG of 1.

FUN can be an anonymous function:

X = fminbnd(@(x) sin(x)+3,2,5)

FUN can be a parameterized function. Use an anonymous function to

capture the problem-dependent parameters:

f = @(x,c) (x-c).^2; % The parameterized function.

c = 1.5; % The parameter.

X = fminbnd(@(x) f(x,c),0,1)

See also optimset, fminsearch, fzero, function_handle.

Reference page in Help browser

doc fminbnd

<fminsearch> - Multidimensional unconstrained nonlinear minimization,

by Nelder-Mead direct search method.

FMINSEARCH Multidimensional unconstrained nonlinear minimization (Nelder-Mead).

X = FMINSEARCH(FUN,X0) starts at X0 and attempts to find a local minimizer

X of the function FUN. FUN is a function handle. FUN accepts input X and

returns a scalar function value F evaluated at X. X0 can be a scalar, vector

or matrix.

X = FMINSEARCH(FUN,X0,OPTIONS) minimizes with the default optimization

parameters replaced by values in the structure OPTIONS, created

with the OPTIMSET function. See OPTIMSET for details. FMINSEARCH uses

these options: Display, TolX, TolFun, MaxFunEvals, MaxIter, FunValCheck,

PlotFcns, and OutputFcn.

X = FMINSEARCH(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a structure with the function FUN in PROBLEM.objective, the start point

in PROBLEM.x0, the options structure in PROBLEM.options, and solver

name 'fminsearch' in PROBLEM.solver. The PROBLEM structure must have

all the fields.

[X,FVAL]= FMINSEARCH(...) returns the value of the objective function,

described in FUN, at X.

[X,FVAL,EXITFLAG] = FMINSEARCH(...) returns an EXITFLAG that describes

the exit condition of FMINSEARCH. Possible values of EXITFLAG and the

corresponding exit conditions are

1 Maximum coordinate difference between current best point and other

points in simplex is less than or equal to TolX, and corresponding

difference in function values is less than or equal to TolFun.

0 Maximum number of function evaluations or iterations reached.

-1 Algorithm terminated by the output function.

[X,FVAL,EXITFLAG,OUTPUT] = FMINSEARCH(...) returns a structure

OUTPUT with the number of iterations taken in OUTPUT.iterations, the

number of function evaluations in OUTPUT.funcCount, the algorithm name

in OUTPUT.algorithm, and the exit message in OUTPUT.message.

Examples

FUN can be specified using @:

X = fminsearch(@sin,3)

finds a minimum of the SIN function near 3.

In this case, SIN is a function that returns a scalar function value

SIN evaluated at X.

FUN can be an anonymous function:

X = fminsearch(@(x) norm(x),[1;2;3])

returns a point near the minimizer [0;0;0].

FUN can be a parameterized function. Use an anonymous function to

capture the problem-dependent parameters:

f = @(x,c) x(1).^2+c.*x(2).^2; % The parameterized function.

c = 1.5; % The parameter.

X = fminsearch(@(x) f(x,c),[0.3;1])

FMINSEARCH uses the Nelder-Mead simplex (direct search) method.

See also optimset, fminbnd, function_handle.

Reference page in Help browser

doc fminsearch

<fzero> - Scalar nonlinear zero finding.

FZERO Single-variable nonlinear zero finding.

X = FZERO(FUN,X0) tries to find a zero of the function FUN near X0,

if X0 is a scalar. It first finds an interval containing X0 where the

function values of the interval endpoints differ in sign, then searches

that interval for a zero. FUN is a function handle. FUN accepts real

scalar input X and returns a real scalar function value F, evaluated

at X. The value X returned by FZERO is near a point where FUN changes

sign (if FUN is continuous), or NaN if the search fails.

X = FZERO(FUN,X0), where X0 is a vector of length 2, assumes X0 is a

finite interval where the sign of FUN(X0(1)) differs from the sign of

FUN(X0(2)). An error occurs if this is not true. Calling FZERO with a

finite interval guarantees FZERO will return a value near a point where

FUN changes sign.

X = FZERO(FUN,X0), where X0 is a scalar value, uses X0 as a starting

guess. FZERO looks for an interval containing a sign change for FUN and

containing X0. If no such interval is found, NaN is returned.

In this case, the search terminates when the search interval

is expanded until an Inf, NaN, or complex value is found. Note: if

the option FunValCheck is 'on', then an error will occur if an NaN or

complex value is found.

X = FZERO(FUN,X0,OPTIONS) solves the equation with the default optimization

parameters replaced by values in the structure OPTIONS, an argument

created with the OPTIMSET function. See OPTIMSET for details. Used

options are Display, TolX, FunValCheck, OutputFcn, and PlotFcns.

X = FZERO(PROBLEM) finds the zero of a function defined in PROBLEM.

PROBLEM is a structure with the function FUN in PROBLEM.objective,

the start point in PROBLEM.x0, the options structure in PROBLEM.options,

and solver name 'fzero' in PROBLEM.solver. The structure PROBLEM must have

all the fields.

[X,FVAL]= FZERO(FUN,...) returns the value of the function described

in FUN, at X.

[X,FVAL,EXITFLAG] = FZERO(...) returns an EXITFLAG that describes the

exit condition of FZERO. Possible values of EXITFLAG and the corresponding

exit conditions are

1 FZERO found a zero X.

-1 Algorithm terminated by output function.

-3 NaN or Inf function value encountered during search for an interval

containing a sign change.

-4 Complex function value encountered during search for an interval

containing a sign change.

-5 FZERO may have converged to a singular point.

-6 FZERO can not detect a change in sign of the function.

[X,FVAL,EXITFLAG,OUTPUT] = FZERO(...) returns a structure OUTPUT

with the number of function evaluations in OUTPUT.funcCount, the

algorithm name in OUTPUT.algorithm, the number of iterations to

find an interval (if needed) in OUTPUT.intervaliterations, the

number of zero-finding iterations in OUTPUT.iterations, and the

exit message in OUTPUT.message.

Examples

FUN can be specified using @:

X = fzero(@sin,3)

returns pi.

X = fzero(@sin,3,optimset('Display','iter'))

returns pi, uses the default tolerance and displays iteration information.

FUN can be an anonymous function:

X = fzero(@(x) sin(3*x),2)

FUN can be a parameterized function. Use an anonymous function to

capture the problem-dependent parameters:

f = @(x,c) cos(c.*x); % The parameterized function.

c = 2; % The parameter.

X = fzero(@(x) myfun(x,c),0.1)

Limitations

X = fzero(@(x) abs(x)+1, 1)

returns NaN since this function does not change sign anywhere on the

real axis (and does not have a zero as well).

X = fzero(@tan,2)

returns X near 1.5708 because the discontinuity of this function near the

point X gives the appearance (numerically) that the function changes sign at X.

See also roots, fminbnd, function_handle.

Reference page in Help browser

doc fzero

Optimization Option handling

<optimset> - Create or alter optimization OPTIONS structure.

OPTIMSET Create/alter optimization OPTIONS structure.

OPTIONS = OPTIMSET('PARAM1',VALUE1,'PARAM2',VALUE2,...) creates an

optimization options structure OPTIONS in which the named parameters have

the specified values. Any unspecified parameters are set to [] (parameters

with value [] indicate to use the default value for that parameter when

OPTIONS is passed to the optimization function). It is sufficient to type

only the leading characters that uniquely identify the parameter. Case is

ignored for parameter names.

NOTE: For values that are strings, the complete string is required.

OPTIONS = OPTIMSET(OLDOPTS,'PARAM1',VALUE1,...) creates a copy of OLDOPTS

with the named parameters altered with the specified values.

OPTIONS = OPTIMSET(OLDOPTS,NEWOPTS) combines an existing options structure

OLDOPTS with a new options structure NEWOPTS. Any parameters in NEWOPTS

with non-empty values overwrite the corresponding old parameters in

OLDOPTS.

OPTIMSET with no input arguments and no output arguments displays all

parameter names and their possible values, with defaults shown in {}

when the default is the same for all functions that use that parameter.

Use OPTIMSET(OPTIMFUNCTION) to see parameters for a specific function.

OPTIONS = OPTIMSET (with no input arguments) creates an options structure

OPTIONS where all the fields are set to [].

OPTIONS = OPTIMSET(OPTIMFUNCTION) creates an options structure with all

the parameter names and default values relevant to the optimization

function named in OPTIMFUNCTION. For example,

optimset('fminbnd')

or

optimset(@fminbnd)

returns an options structure containing all the parameter names and

default values relevant to the function 'fminbnd'.

OPTIMSET PARAMETERS for MATLAB

Display - Level of display [ off | iter | notify | final ]

MaxFunEvals - Maximum number of function evaluations allowed

[ positive integer ]

MaxIter - Maximum number of iterations allowed [ positive scalar ]

TolFun - Termination tolerance on the function value [ positive scalar ]

TolX - Termination tolerance on X [ positive scalar ]

FunValCheck - Check for invalid values, such as NaN or complex, from

user-supplied functions [ {off} | on ]

OutputFcn - Name(s) of output function [ {[]} | function ]

All output functions are called by the solver after each

iteration.

PlotFcns - Name(s) of plot function [ {[]} | function ]

Function(s) used to plot various quantities in every iteration

Note to Optimization Toolbox users:

To see the parameters for a specific function, check the documentation page

for that function. For instance, enter

doc fmincon

to open the reference page for fmincon.

You can also see the options in the Optimization Tool. Enter

optimtool

Examples:

To create an options structure with the default parameters for FZERO

options = optimset('fzero');

To create an options structure with TolFun equal to 1e-3

options = optimset('TolFun',1e-3);

To change the Display value of options to 'iter'

options = optimset(options,'Display','iter');

See also optimget, fzero, fminbnd, fminsearch, lsqnonneg.

Overloaded methods:

cgoptimstore/optimset

ResponseOptimizer.optimset

ParameterEstimator.optimset

Reference page in Help browser

doc optimset

<optimget> - Get optimization parameters from OPTIONS structure.

OPTIMGET Get OPTIM OPTIONS parameters.

VAL = OPTIMGET(OPTIONS,'NAME') extracts the value of the named parameter

from optimization options structure OPTIONS, returning an empty matrix if

the parameter value is not specified in OPTIONS. It is sufficient to

type only the leading characters that uniquely identify the

parameter. Case is ignored for parameter names. [] is a valid OPTIONS

argument.

VAL = OPTIMGET(OPTIONS,'NAME',DEFAULT) extracts the named parameter as above, but returns DEFAULT if the named parameter is not specified (is [])

in OPTIONS. For example

val = optimget(opts,'TolX',1e-4);

returns val = 1e-4 if the TolX parameter is not specified in opts.

See also optimset.

Overloaded methods:

ResponseOptimizer.optimget

ParameterEstimator.optimget

Reference page in Help browser

doc optimget

Numerical integration (quadrature)

<quad> - Numerically evaluate integral, low order method.

QUAD Numerically evaluate integral, adaptive Simpson quadrature.

Q = QUAD(FUN,A,B) tries to approximate the integral of scalar-valued

function FUN from A to B to within an error of 1.e-6 using recursive

adaptive Simpson quadrature. FUN is a function handle. The function

Y=FUN(X) should accept a vector argument X and return a vector result

Y, the integrand evaluated at each element of X.

Q = QUAD(FUN,A,B,TOL) uses an absolute error tolerance of TOL

instead of the default, which is 1.e-6. Larger values of TOL

result in fewer function evaluations and faster computation,

but less accurate results. The QUAD function in MATLAB 5.3 used

a less reliable algorithm and a default tolerance of 1.e-3.

Q = QUAD(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values

of [fcnt a b-a Q] during the recursion. Use [] as a placeholder to

obtain the default value of TOL.

[Q,FCNT] = QUAD(...) returns the number of function evaluations.

Use array operators .*, ./ and .^ in the definition of FUN

so that it can be evaluated with a vector argument.

Notes:

QUAD may be most efficient for low accuracies with nonsmooth

integrands.

QUADL may be more efficient than QUAD at higher accuracies

with smooth integrands.

QUADGK may be most efficient for oscillatory integrands and any smooth

integrand at high accuracies. It supports infinite intervals and can

handle moderate singularities at the endpoints. It also supports

contour integration along piecewise linear paths.

QUADV vectorizes QUAD for array-valued FUN.

Example:

Q = quad(@myfun,0,2);

where the file myfun.m defines the function:

%-------------------%

function y = myfun(x)

y = 1./(x.^3-2*x-5);

%-------------------%

or, use a parameter for the constant:

Q = quad(@(x)myfun2(x,5),0,2);

where the file myfun2.m defines the function:

%----------------------%

function y = myfun2(x,c)

y = 1./(x.^3-2*x-c);

%----------------------%

Class support for inputs A, B, and the output of FUN:

float: double, single

See also quadv, quadl, quadgk, quad2d, dblquad, triplequad, trapz, function_handle.

Reference page in Help browser

doc quad

<quadgk> - Numerically evaluate integral, adaptive Gauss-Kronrod quadrature.

QUADGK Numerically evaluate integral, adaptive Gauss-Kronrod quadrature.

Q = QUADGK(FUN,A,B) attempts to approximate the integral of

scalar-valued function FUN from A to B using high order global adaptive

quadrature and default error tolerances. The function Y=FUN(X) should

accept a vector argument X and return a vector result Y, the integrand

evaluated at each element of X. FUN must be a function handle. A and B

can be -Inf or Inf. If both are finite, they can be complex. If at

least one is complex, the integral is approximated over a straight line

path from A to B in the complex plane.

[Q,ERRBND] = QUADGK(...). ERRBND is an approximate upper bound on the

absolute error, |Q - I|, where I denotes the exact value of the

integral.

[Q,ERRBND] = QUADGK(FUN,A,B,PARAM1,VAL1,PARAM2,VAL2,...) performs

the integration with specified values of optional parameters. The

available parameters are

'AbsTol', absolute error tolerance

'RelTol', relative error tolerance

QUADGK attempts to satisfy ERRBND <= max(AbsTol,RelTol*|Q|). This

is absolute error control when |Q| is sufficiently small and

relative error control when |Q| is larger. A default tolerance

value is used when a tolerance is not specified. The default value

of 'AbsTol' is 1.e-10 (double), 1.e-5 (single). The default value

of 'RelTol' is 1.e-6 (double), 1.e-4 (single). For pure absolute

error control use

Q = quadgk(FUN,A,B,'AbsTol',ATOL,'RelTol',0)

where ATOL > 0. For pure relative error control use

Q = quadgk(FUN,A,B,'RelTol',RTOL,'AbsTol',0)

Except when using pure absolute error control, the minimum relative

tolerance is 100*eps(class(Q)).

'Waypoints', vector of integration waypoints

If FUN(X) has discontinuities in the interval of integration, the

locations should be supplied as a 'Waypoints' vector. When A, B,

and the waypoints are all real, only the waypoints between A and B

are used, and they are used in sorted order. Note that waypoints

are not intended for singularities in FUN(X). Singular points

should be handled by making them endpoints of separate integrations

and adding the results.

If A, B, or any entry of the waypoints vector is complex, the

integration is performed over a sequence of straight line paths in

the complex plane, from A to the first waypoint, from the first

waypoint to the second, and so forth, and finally from the last

waypoint to B.

'MaxIntervalCount', maximum number of intervals allowed

The 'MaxIntervalCount' parameter limits the number of intervals

that QUADGK will use at any one time after the first iteration. A

warning is issued if QUADGK returns early because of this limit.

The default value is 650. Increasing this value is not recommended,

but it may be appropriate when ERRBND is small enough that the

desired accuracy has nearly been achieved.

Notes:

QUAD may be most efficient for low accuracies with nonsmooth

integrands.

QUADL may be more efficient than QUAD at higher accuracies

with smooth integrands.

QUADGK may be most efficient for oscillatory integrands and any smooth

integrand at high accuracies. It supports infinite intervals and can

handle moderate singularities at the endpoints. It also supports

contour integration along piecewise linear paths.

QUADV vectorizes QUAD for array-valued FUN.

Example:

Integrate f(x) = exp(-x^2)*log(x)^2 from 0 to infinity:

f = @(x) exp(-x.^2).*log(x).^2

Q = quadgk(f,0,Inf)

Example:

To use a parameter in the integrand:

f = @(x,c) 1./(x.^3-2*x-c);

Q = quadgk(@(x)f(x,5),0,2);

Example:

Integrate f(z) = 1/(2z-1) in the complex plane over the triangular

path from 0 to 1+1i to 1-1i to 0:

Q = quadgk(@(z)1./(2*z-1),0,0,'Waypoints',[1+1i,1-1i])

Class support for inputs A, B, and the output of FUN:

float: double, single

See also quad, quadl, quadv, quad2d, dblquad, triplequad, function_handle

Reference page in Help browser

doc quadgk

<quadl> - Numerically evaluate integral, higher order method.

QUADL Numerically evaluate integral, adaptive Lobatto quadrature.

Q = QUADL(FUN,A,B) tries to approximate the integral of scalar-valued

function FUN from A to B to within an error of 1.e-6 using high order

recursive adaptive quadrature. FUN is a function handle. The function

Y=FUN(X) should accept a vector argument X and return a vector result

Y, the integrand evaluated at each element of X.

Q = QUADL(FUN,A,B,TOL) uses an absolute error tolerance of TOL

instead of the default, which is 1.e-6. Larger values of TOL

result in fewer function evaluations and faster computation,

but less accurate results.

Q = QUADL(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values

of [fcnt a b-a Q] during the recursion. Use [] as a placeholder to

obtain the default value of TOL.

[Q,FCNT] = QUADL(...) returns the number of function evaluations.

Use array operators .*, ./ and .^ in the definition of FUN

so that it can be evaluated with a vector argument.

Notes:

QUAD may be most efficient for low accuracies with nonsmooth

integrands.

QUADL may be more efficient than QUAD at higher accuracies

with smooth integrands.

QUADGK may be most efficient for oscillatory integrands and any smooth

integrand at high accuracies. It supports infinite intervals and can

handle moderate singularities at the endpoints. It also supports

contour integration along piecewise linear paths.

QUADV vectorizes QUAD (not QUADL) for array-valued FUN.

Example:

Q = quadl(@myfun,0,2);

where the file myfun.m defines the function:

%-------------------%

function y = myfun(x)

y = 1./(x.^3-2*x-5);

%-------------------%

or, use a parameter for the constant:

Q = quadl(@(x)myfun2(x,5),0,2);

where the file myfun2.m defines the function:

%----------------------%

function y = myfun2(x,c)

y = 1./(x.^3-2*x-c);

%----------------------%

Class support for inputs A, B, and the output of FUN:

float: double, single

See also quad, quadgk, quadv, quad2d, dblquad, triplequad, trapz, function_handle.

Reference page in Help browser

doc quadl

<quadv> - Vectorized QUAD.

QUADV Vectorized QUAD.

Q = QUADV(FUN,A,B) approximates the integral of the complex

array-valued function FUN from A to B to within an error of 1.e-6 using

recursive adaptive Simpson quadrature. FUN is a function handle. The

function Y=FUN(X) should accept a scalar argument X and return an array

result Y, whose components are the integrands evaluated at X.

Q = QUADV(FUN,A,B,TOL) uses the absolute error tolerance TOL for all

the integrals instead of the default, which is 1.e-6.

Q = QUADV(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values

of [fcnt a b-a Q(1)] during the recursion. Use [] as a placeholder to

obtain the default value of TOL.

[Q,FCNT] = QUADV(...) returns the number of function evaluations.

Note: The same tolerance is used for all components, so the results

obtained with QUADV are usually not the same as those obtained with

QUAD on the individual components.

Example:

For the parameterized array-valued function myarrayfun:

%--------------------------%

function Y = myarrayfun(x,n)

Y = 1./((1:n)+x);

%--------------------------%

integrate using parameter value n=10 between a=0 and b=1:

Qv = quadv(@(x)myarrayfun(x,10),0,1);

The resulting array Qv has elements estimating Q(k) = log((k+1)./(k)).

Qv is slightly different than if computed using QUAD in a loop:

for k = 1:10

Qs(k) = quad(@(x)myscalarfun(x,k),0,1);

end

where myscalarfun is:

%---------------------------%

function y = myscalarfun(x,k)

y = 1./(k+x);

%---------------------------%

Class support for inputs A, B, and the output of FUN:

float: double, single

See also quad, quadl, quadgk, quad2d, dblquad, triplequad, function_handle.

Reference page in Help browser

doc quadv

<quad2d> - Numerically evaluate double integral over a planar region.

QUAD2D Numerically evaluate double integral over a planar region.

Q = QUAD2D(FUN,A,B,C,D) approximates the integral of FUN(X,Y) over the

planar region A <= X <= B and C(X) <= Y <= D(X). FUN is a function

handle, C and D may each be a scalar or a function handle.

All input functions must be vectorized:

The function Z=FUN(X,Y) must accept 2D matrices X and Y of the same

size and return a matrix Z of corresponding values. The functions

YMIN=C(X) and YMAX=D(X) must accept matrices and return matrices of the

same size with corresponding values.

[Q,ERRBND] = QUAD2D(...). ERRBND is an approximate upper bound on the

absolute error, |Q - I|, where I denotes the exact value of the

integral.

[Q,ERRBND] = QUAD2D(FUN,A,B,C,D,PARAM1,VAL1,PARAM2,VAL2,...) performs the integration as above with specified values of optional parameters:

'AbsTol', absolute error tolerance

'RelTol', relative error tolerance

QUAD2D attempts to satisfy ERRBND <= max(AbsTol,RelTol*|Q|). This

is absolute error control when |Q| is sufficiently small and

relative error control when |Q| is larger. A default tolerance

value is used when a tolerance is not specified. The default value

of 'AbsTol' is 1e-5. The default value of 'RelTol' is

100*eps(class(Q)). This is also the minimum value of 'RelTol'.

Smaller 'RelTol' values are automatically increased to the default

value.

'MaxFunEvals', maximum number of evaluations of FUN allowed

The 'MaxFunEvals' parameter limits the number of vectorized calls

to FUN. The default is 2000.

'FailurePlot', generate a plot if MaxFunEvals is reached

Setting 'FailurePlot' to TRUE generates a graphical representation

of the regions needing further refinement when MaxFunEvals is

reached. No plot is generated if the integration succeeds before

reaching MaxFunEvals. The default is FALSE.

'Singular', problem may have boundary singularities

With 'Singular' set to TRUE, QUAD2D will employ transformations to

weaken boundary singularities for better performance. The default

is TRUE.

Example:

Integrate y*sin(x)+x*cos(y) over pi <= x <= 2*pi, 0 <= y <= pi.

The true value of the integral is -pi^2.

Q = quad2d(@(x,y) y.*sin(x)+x.*cos(y),pi,2*pi,0,pi)

Example:

Integrate 1./(sqrt(x+y).*(1+x+y).^2 over the triangle 0 <= x <= 1,

0 <= y <= 1-x. The integrand is infinite at (0,0). The true value of

the integral is pi/4 - 1/2.

fun = @(x,y) 1./( sqrt(x + y) .* (1 + x + y).^2 )

% In Cartesian coordinates:

ymax = @(x) 1 - x

Q = quad2d(fun,0,1,0,ymax)

% In polar coordinates:

polarfun = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r

rmax = @(theta) 1./(sin(theta) + cos(theta))

Q = quad2d(polarfun,0,pi/2,0,rmax)

Class support for inputs A, B, C, D, and the output of FUN:

float: double, single

See also dblquad, triplequad, quadgk, trapz, function_handle, arrayfun.

Overloaded methods:

sfit/quad2d

Reference page in Help browser

doc quad2d

<dblquad> - Numerically evaluate double integral over a rectangle.

DBLQUAD Numerically evaluate double integral over a rectangle.

Q = DBLQUAD(FUN,XMIN,XMAX,YMIN,YMAX) evaluates the double integral of

FUN(X,Y) over the rectangle XMIN <= X <= XMAX, YMIN <= Y <= YMAX. FUN

is a function handle. The function Z=FUN(X,Y) should accept a vector X

and a scalar Y and return a vector Z of values of the integrand.

Q = DBLQUAD(FUN,XMIN,XMAX,YMIN,YMAX,TOL) uses a tolerance TOL instead

of the default, which is 1.e-6.

Q = DBLQUAD(FUN,XMIN,XMAX,YMIN,YMAX,TOL,@QUADL) uses quadrature

function QUADL instead of the default QUAD.

Q = DBLQUAD(FUN,XMIN,XMAX,YMIN,YMAX,TOL,MYQUADF) uses your own

quadrature function MYQUADF instead of QUAD. MYQUADF is a function

handle. MYQUADF should have the same calling sequence as QUAD and

QUADL. Use [] as a placeholder to obtain the default value of TOL.

QUADGK is not supported directly as a quadrature function for

DBLQUAD, but it can be called from MYQUADF.

Example:

Integrate over the square pi <= x <= 2*pi, 0 <= y <= pi:

integrnd = @(x,y) y.*sin(x)+x.*cos(y);

Q = dblquad(integrnd, pi, 2*pi, 0, pi)

Note the integrand can be evaluated with a vector x and a scalar y.

Nonsquare regions can be handled by setting the integrand to zero

outside of the region. The volume of a hemisphere is:

V = dblquad(@(x,y) sqrt(max(1-(x.^2+y.^2),0)),-1,1,-1,1)

or

V = dblquad(@(x,y) sqrt(1-(x.^2+y.^2)).*(x.^2+y.^2<=1),-1,1,-1,1)

Class support for inputs XMIN,XMAX,YMIN,YMAX and the output of FUN:

float: double, single

See also quad2d, quad, quadl, quadgk, triplequad, trapz, function_handle.

Reference page in Help browser

doc dblquad

<triplequad> - Numerically evaluate triple integral.

TRIPLEQUAD Numerically evaluate triple integral.

Q = TRIPLEQUAD(FUN,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX) evaluates the triple

integral of FUN(X,Y,Z) over the three dimensional rectangular region

XMIN <= X <= XMAX, YMIN <= Y <= YMAX, ZMIN <= Z <= ZMAX. FUN is a

function handle. The function V=FUN(X,Y,Z) should accept a vector X and

scalar Y and Z and return a vector V of values of the integrand.

Q = TRIPLEQUAD(FUN,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX,TOL) uses a tolerance

TOL instead of the default, which is 1.e-6.

Q = TRIPLEQUAD(FUN,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX,TOL,@QUADL) uses

quadrature function QUADL instead of the default QUAD.

Q = TRIPLEQUAD(FUN,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX,TOL,MYQUADF) uses

your own quadrature function MYQUADF instead of QUAD. MYQUADF is a

function handle. MYQUADF should have the same calling sequence as QUAD

and QUADL. Use [] as a placeholder to obtain the default value of TOL.

QUADGK is not supported directly as a quadrature function for

TRIPLEQUAD, but it can be called from MYQUADF.

Example:

Integrate over the region 0 <= x <= pi, 0 <= y <= 1, -1 <= z <= 1:

integrnd = @(x,y,z) y.*six(x)+z.*cos(x);

Q = triplequad(integrnd, 0, pi, 0, 1, -1, 1)

Note the integrand can be evaluated with a vector x and scalars y and z.

Class support for inputs XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX and the output of FUN:

float: double, single

See also quad, quadl, quadgk, quad2d, dblquad, function_handle.

Reference page in Help browser

doc triplequad

Plotting

<ezplot> - Easy to use function plotter.

EZPLOT Easy to use function plotter

EZPLOT(FUN) plots the function FUN(X) over the default domain

-2*PI < X < 2*PI, where FUN(X) is an explicitly defined function of X.

EZPLOT(FUN2) plots the implicitly defined function FUN2(X,Y) = 0 over

the default domain -2*PI < X < 2*PI and -2*PI < Y < 2*PI.

EZPLOT(FUN,[A,B]) plots FUN(X) over A < X < B.

EZPLOT(FUN2,[A,B]) plots FUN2(X,Y) = 0 over A < X < B and A < Y < B.

EZPLOT(FUN2,[XMIN,XMAX,YMIN,YMAX]) plots FUN2(X,Y) = 0 over

XMIN < X < XMAX and YMIN < Y < YMAX.

EZPLOT(FUNX,FUNY) plots the parametrically defined planar curve FUNX(T)

and FUNY(T) over the default domain 0 < T < 2*PI.

EZPLOT(FUNX,FUNY,[TMIN,TMAX]) plots FUNX(T) and FUNY(T) over

TMIN < T < TMAX.

EZPLOT(FUN,[A,B],FIG), EZPLOT(FUN2,[XMIN,XMAX,YMIN,YMAX],FIG), or EZPLOT(FUNX,FUNY,[TMIN,TMAX],FIG) plots the function over the

specified domain in the figure window FIG.

EZPLOT(AX,...) plots into AX instead of GCA or FIG.

H = EZPLOT(...) returns handles to the plotted objects in H.

Examples:

The easiest way to express a function is via a string:

ezplot('x^2 - 2*x + 1')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezplot('x.*y + x.^2 - y.^2 - 1')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezplot(@humps)

ezplot(@cos,@sin)

EZPLOT plots the variables in string expressions alphabetically.

subplot(1,2,1), ezplot('1./z - log(z) + log(-1+z) + t - 1')

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezplot(@(z,t)1./z - log(z) + log(-1+z) + t - 1)

If your function has additional parameters, for example k in myfun:

%-----------------------%

function z = myfun(x,y,k)

z = x.^k - y.^k - 1;

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezplot(@(x,y)myfun(x,y,2))

See also ezcontour, ezcontourf, ezmesh, ezmeshc, ezplot3, ezpolar,

ezsurf, ezsurfc, plot, vectorize, function_handle.

Overloaded methods:

sym/ezplot

Reference page in Help browser

doc ezplot

<ezplot3> - Easy to use 3-D parametric curve plotter.

EZPLOT3 Easy to use 3-d parametric curve plotter

EZPLOT3(FUNX,FUNY,FUNZ) plots the spatial curve FUNX(T), FUNY(T), and

FUNZ(T) over the default domain 0 < T < 2*PI.

EZPLOT3(FUNX,FUNY,FUNZ,[TMIN,TMAX]) plots the curve FUNX(T), FUNY(T),

and FUNZ(T) over TMIN < T < TMAX.

EZPLOT3(FUNX,FUNY,FUNZ,'animate') or

EZPLOT(FUNX,FUNY,FUNZ,[TMIN,TMAX],'animate') produces an animated trace

of the spatial curve.

EZPLOT3(AX,...) plots into AX instead of GCA.

H = EZPLOT3(...) returns handles to the plotted objects in H.

Examples:

The easiest way to express a function is via a string:

ezplot3('cos(t)','t*sin(t)','sqrt(t)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezplot3('cos(t)','t.*sin(t)','sqrt(t)')

You may also use a function handle to an existing function or an

anonymous function. These are more powerful and efficient than string

expressions.

ezplot3(@cos,@(t)t.*sin(t),@sqrt)

If your function has additional parameters, for example k in myfuntk:

%-----------------------%

function s = myfuntk(t,k)

s = t.^k .* sin(t);

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezplot3(@cos,@(t)myfuntk(t,1),@sqrt)

See also ezcontour, ezcontourf, ezmesh, ezmeshc, ezplot, ezpolar,

ezsurf, ezsurfc, plot, plot3, vectorize, function_handle.

Overloaded methods:

sym/ezplot3

Reference page in Help browser

doc ezplot3

<ezpolar> - Easy to use polar coordinate plotter.

EZPOLAR Easy to use polar coordinate plotter.

EZPOLAR(FUN) plots the polar curve RHO = FUN(THETA) over the default

domain 0 < theta < 2*pi.

EZPOLAR(FUN,[A,B]) plots FUN for A < THETA < B.

EZPOLAR(AX,...) plots into AX instead of GCA.

H = EZPOLAR(...) returns a handle to the plotted object in H.

Examples

The easiest way to express a function is via a string:

ezpolar('sin(2*t)*cos(3*t)',[0 pi])

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezpolar('sin(2*t).*cos(3*t)',[0 pi])

You may also use a function handle to an existing function or an

anonymous function. These are more powerful and efficient than string

expressions.

ezpolar(@cos)

ezpolar(@(t)sin(3*t))

If your function has additional parameters, for example k1,k2 in myfun:

%-------------------------%

function s = myfun(t,k1,k2)

s = sin(k1*t).*cos(k2*t);

%-------------------------%

then you may use an anonymous function to specify the parameters:

ezpolar(@(t)myfun(t,2,3))

See also ezplot3, ezplot, ezsurf, plot, plot3, polar, vectorize,

function_handle.

Overloaded methods:

sym/ezpolar

Reference page in Help browser

doc ezpolar

<ezcontour> - Easy to use contour plotter.

EZCONTOUR Easy to use contour plotter

EZCONTOUR(FUN) plots the contour lines of FUN(X,Y) using CONTOUR. FUN

is plotted over the default domain -2*PI < X < 2*PI, -2*PI < Y < 2*PI.

EZCONTOUR(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of

the default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX]

or the vector [A,B] (to plot over A < X < B and A < Y < B).

EZCONTOUR(...,N) plots FUN over the default domain using an N-by-N

grid. The default value for N is 60.

EZCONTOUR(AX,...) plots into AX instead of GCA.

H = EZCONTOUR(...) returns handles to contour objects in H.

Examples:

The easiest way to express a function is via a string:

ezcontour('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezcontour('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezcontour(@peaks)

EZCONTOUR plots the variables in string expressions alphabetically.

subplot(1,2,1), ezcontour('x.*exp(-x.^2 - y.^2)')

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezcontour(@(y,x)x.*exp(-x.^2 - y.^2))

If your function has additional parameters, for example k in myfun:

%-----------------------%

function z = myfun(x,y,k)

z = x.^k - y.^k - 1;

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezcontour(@(x,y)myfun(x,y,2))

See also ezplot, ezplot3, ezpolar, ezcontourf, ezsurf, ezmesh,

ezsurfc, ezmeshc, contour, vectorize, function_handle.

Overloaded methods:

sym/ezcontour

Reference page in Help browser

doc ezcontour

<ezcontourf> - Easy to use filled contour plotter.

EZCONTOURF Easy to use filled contour plotter

EZCONTOURF(FUN) plots the contour lines of FUN(X,Y) using CONTOURF. FUN

is plotted over the default domain -2*PI < X < 2*PI, -2*PI < Y < 2*PI.

EZCONTOURF(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of

the default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX] or

the vector [A,B] (to plot over A < X < B and A < Y < B).

EZCONTOURF(...,N) plots FUN over the default domain using an N-by-N

grid. The default value for N is 60.

EZCONTOURF(AX,...) plots into AX instead of GCA.

H = EZCONTOURF(...) returns handles to contour objects in H.

Examples:

The easiest way to express a function is via a string:

ezcontourf('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezcontourf('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezcontourf(@peaks)

EZCONTOURF plots the variables in string expressions alphabetically.

subplot(1,2,1), ezcontourf('x.*exp(-x.^2 - y.^2)')

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezcontourf(@(y,x)x.*exp(-x.^2 - y.^2))

If your function has additional parameters, for example k in myfun:

%-----------------------%

function z = myfun(x,y,k)

z = x.^k - y.^k - 1;

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezcontourf(@(x,y)myfun(x,y,2))

See also ezplot, ezplot3, ezpolar, ezcontour, ezsurf, ezmesh,

ezsurfc, ezmeshc, contourf, vectorize, function_handle.

Overloaded methods:

sym/ezcontourf

Reference page in Help browser

doc ezcontourf

<ezmesh> - Easy to use 3-D mesh plotter.

EZMESH Easy to use 3-D mesh plotter

EZMESH(FUN) plots a graph of FUN(X,Y) using MESH. FUN is plotted over

the default domain -2*PI < X < 2*PI and -2*PI < Y < 2*PI.

EZMESH(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of the

default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX] or the

vector [A,B] (to plot over A < X < B and A < Y < B).

EZMESH(FUNX,FUNY,FUNZ) plots the parametric surface FUNX(S,T),

FUNY(S,T), and FUNZ(S,T) over the domain -2*PI < S < 2*PI and

-2*PI < T < 2*PI.

EZMESH(FUNX,FUNY,FUNZ,[SMIN,SMAX,TMIN,TMAX]) or

EZMESH(FUNX,FUNY,FUNZ,[A,B]) uses the specified domain.

EZMESH(...,N) plots the function over the default domain using an

N-by-N grid. The default value for N is 60.

EZMESH(...,'circ') plots the function over a disk centered on the

domain.

EZMESH(AX,...) plots into AX instead of GCA.

H = EZMESH(...) returns a handle to the plotted object in H.

Examples:

The easiest way to express a function is via a string:

ezmesh('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezmesh('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezmesh(@peaks)

EZMESH plots the variables in string expressions alphabetically.

subplot(1,2,1), ezmesh('exp(-x).*cos(t)',[-4*pi,4*pi,-2,2])

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezmesh(@(x,t)exp(-x).*cos(t),[-2,2,-4*pi,4*pi])

If your function has additional parameters, for example k in myfun:

%-----------------------%

function z = myfun(x,y,k)

z = - x.^k - y.^k;

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezmesh(@(x,y)myfun(x,y,2))

See also ezplot, ezplot3, ezpolar, ezcontour, ezcontourf, ezsurf,

ezsurfc, ezmeshc, mesh, vectorize, function_handle.

Overloaded methods:

sym/ezmesh

Reference page in Help browser

doc ezmesh

<ezmeshc> - Easy to use combination mesh/contour plotter.

EZMESHC Easy to use combination mesh/contour plotter

EZMESHC(FUN) plots a graph of FUN(X,Y) using MESHC. FUN is plotted over

the default domain -2*PI < X < 2*PI and -2*PI < Y < 2*PI.

EZMESHC(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of the

default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX] or the

vector [A,B] (to plot over A < X < B and A < Y < B).

EZMESHC(FUNX,FUNY,FUNZ) plots the parametric surface FUNX(S,T),

FUNY(S,T), FUNZ(S,T) over the domain -2*PI < S < 2*PI and

-2*PI < T < 2*PI.

EZMESHC(FUNX,FUNY,FUNZ,[SMIN,SMAX,TMIN,TMAX]) or

EZMESHC(FUNX,FUNY,FUNZ,[A,B]) uses the specified domain.

EZMESHC(...,N) plots the function over the default domain using an

N-by-N grid. The default value for N is 60.

EZMESHC(...,'circ') plots the function over a disk centered on the

domain.

EZMESHC(AX,...) plots into AX instead of GCA.

H = EZMESHC(...) returns handles to plotted objects in H.

Examples:

The easiest way to express a function is via a string:

ezmeshc('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezmeshc('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezmeshc(@peaks)

EZMESHC plots the variables in string expressions alphabetically.

subplot(1,2,1), ezmeshc('exp(-x).*cos(t)',[-4*pi,4*pi,-2,2])

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezmeshc(@(x,t)exp(-x).*cos(t),[-2,2,-4*pi,4*pi])

If your function has additional parameters, for example k in myfun:

%-----------------------%

function z = myfun(x,y,k)

z = - x.^k - y.^k;

%-----------------------%

then you may use an anonymous function to specify that parameter:

ezmeshc(@(x,y)myfun(x,y,2))

See also ezplot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh,

ezsurf, ezsurfc, meshc, vectorize, function_handle.

Overloaded methods:

sym/ezmeshc

Reference page in Help browser

doc ezmeshc

<ezsurf> - Easy to use 3-D colored surface plotter.

EZSURF Easy to use 3-D colored surface plotter

EZSURF(FUN) plots a graph of the function FUN(X,Y) using SURF. FUN is

plotted over the default domain -2*PI < X < 2*PI, -2*PI < Y < 2*PI.

EZSURF(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of the

default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX] or the

vector [A,B] (to plot over A < X < B, A < Y < B).

EZSURF(FUNX,FUNY,FUNZ) plots the parametric surface FUNX(S,T),

FUNY(S,T), and FUNZ(S,T) over the square -2*PI < S < 2*PI and

-2*PI < T < 2*PI.

EZSURF(FUNX,FUNY,FUNZ,[SMIN,SMAX,TMIN,TMAX]) or

EZSURF(FUNX,FUNY,FUNZ,[A,B]) uses the specified domain.

EZSURF(...,N) plots f over the default domain using an N-by-N grid.

The default value for N is 60.

EZSURF(...,'circ') plots f over a disk centered on the domain.

EZSURF(AX,...) plots into AX instead of GCA.

H = EZSURF(...) returns a handle to the surface object in H.

Examples:

The easiest way to express a function is via a string:

ezsurf('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezsurf('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezsurf(@peaks)

EZSURF plots the variables in string expressions alphabetically.

subplot(1,2,1), ezsurf('u.*(v.^2)./(u.^2 + v.^4)')

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezsurf(@(v,u)u.*(v.^2)./(u.^2 + v.^4))

If your function has additional parameters, for example k in myfun:

%------------------------------%

function z = myfun(x,y,k1,k2,k3)

z = x.*(y.^k1)./(x.^k2 + y.^k3);

%------------------------------%

then you may use an anonymous function to specify that parameter:

ezsurf(@(x,y)myfun(x,y,2,2,4))

See also ezplot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh,

ezsurfc, ezmeshc, surf, vectorize, function_handle.

Overloaded methods:

sym/ezsurf

Reference page in Help browser

doc ezsurf

<ezsurfc> - Easy to use combination surf/contour plotter.

EZSURFC Easy to use combination surf/contour plotter.

EZSURFC(FUN) plots a graph of the function FUN(X,Y) using SURFC. FUN is

plotted over the default domain -2*PI < X < 2*PI, -2*PI < Y < 2*PI.

EZSURFC(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of the

default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX] or the

[A,B] (to plot over A < X < B, A < Y < B).

EZSURFC(FUNX,FUNY,FUNZ) plots the parametric surface FUNX(S,T),

FUNY(S,T), and FUNZ(S,T) over the square -2*PI < S < 2*PI and

-2*PI < T < 2*PI.

EZSURFC(FUNX,FUNY,FUNZ,[SMIN,SMAX,TMIN,TMAX]) or

EZSURFC(FUNX,FUNY,FUNZ,[A,B]) uses the specified domain.

EZSURFC(...,N) plots FUN over the default domain using an N-by-N grid.

The default value for N is 60.

EZSURFC(...,'circ') plots FUN over a disk centered on the domain.

EZSURFC(AX,...) plots into AX instead of GCA.

H = EZSURFC(...) returns handles to the plotted object in H.

Examples:

The easiest way to express a function is via a string:

ezsurfc('x*exp(-x^2 - y^2)')

One programming technique is to vectorize the string expression using

the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).

This makes the algorithm more efficient since it can perform multiple

function evaluations at once.

ezsurfc('x.*exp(-x.^2 - y.^2)')

You may also use a function handle to an existing function. Function

handles are more powerful and efficient than string expressions.

ezsurfc(@peaks)

EZSURFC plots the variables in string expressions alphabetically.

subplot(1,2,1), ezsurfc('u.*(v.^2)./(u.^2 + v.^4)')

To avoid this ambiguity, specify the order with an anonymous function:

subplot(1,2,2), ezsurfc(@(v,u)u.*(v.^2)./(u.^2 + v.^4))

If your function has additional parameters, for example k in myfun:

%------------------------------%

function z = myfun(x,y,k1,k2,k3)

z = x.*(y.^k1)./(x.^k2 + y.^k3);

%------------------------------%

then you may use an anonymous function to specify that parameter:

ezsurfc(@(x,y)myfun(x,y,2,2,4))

See also ezplot, ezplot3, ezpolar, ezcontour, ezcontourf, ezmesh,

ezsurf, ezmeshc, surfc, vectorize, function_handle.

Overloaded methods:

sym/ezsurfc

Reference page in Help browser

doc ezsurfc

<fplot> - Plot function.

FPLOT Plot function

FPLOT(FUN,LIMS) plots the function FUN between the x-axis limits

specified by LIMS = [XMIN XMAX]. Using LIMS = [XMIN XMAX YMIN YMAX]

also controls the y-axis limits. FUN(x) must return a row vector for

each element of vector x. For example, if FUN returns

[f1(x),f2(x),f3(x)] then for input [x1;x2] FUN should return

[f1(x1) f2(x1) f3(x1);

f1(x2) f2(x2) f3(x2)]

FPLOT(FUN,LIMS,TOL) with TOL < 1 specifies the relative error

tolerance. The default TOL is 2e-3, i.e. 0.2 percent accuracy.

FPLOT(FUN,LIMS,N) with N >= 1 plots the function with a minimum of N+1

points. The default N is 1. The maximum step size is restricted to be

(1/N)*(XMAX-XMIN).

FPLOT(FUN,LIMS,'LineSpec') plots with the given line specification.

FPLOT(FUN,LIMS,...) accepts combinations of the optional arguments

TOL, N, and 'LineSpec', in any order.

[X,Y] = FPLOT(FUN,LIMS,...) returns X and Y such that Y = FUN(X). No

plot is drawn on the screen.

FPLOT(AX,...) plots into AX instead of GCA.

Examples:

fplot(@humps,[0 1])

fplot(@(x)[tan(x),sin(x),cos(x)], 2*pi*[-1 1 -1 1])

fplot(@(x) sin(1./x), [0.01 0.1], 1e-3)

f = @(x,n)abs(exp(-1j*x*(0:n-1))*ones(n,1));

fplot(@(x)f(x,10),[0 2*pi])

See also plot, ezplot, function_handle.

Reference page in Help browser

doc fplot

Inline function object

<inline> - Construct INLINE function object.

INLINE Construct INLINE object.

INLINE(EXPR) constructs an inline function object from the

MATLAB expression contained in the string EXPR. The input

arguments are automatically determined by searching EXPR

for variable names (see SYMVAR). If no variable exists, 'x'

is used.

INLINE(EXPR, ARG1, ARG2, ...) constructs an inline

function whose input arguments are specified by the

strings ARG1, ARG2, ... Multicharacter symbol names may

be used.

INLINE(EXPR, N), where N is a scalar, constructs an

inline function whose input arguments are 'x', 'P1',

'P2', ..., 'PN'.

Examples:

g = inline('t^2')

g = inline('sin(2*pi*f + theta)')

g = inline('sin(2*pi*f + theta)', 'f', 'theta')

g = inline('x^P1', 1)

See also symvar.

Overloaded methods:

laurpoly/inline

Reference page in Help browser

doc inline

<argnames> - Argument names.

--- help for inline/argnames ---

ARGNAMES Argument names.

ARGNAMES(FUN) returns the names of the input arguments of the

INLINE object FUN as a cell array of strings.

See also inline/formula.

Overloaded methods:

fittype/argnames

Reference page in Help browser

doc inline/argnames

<formula> - Function formula.

--- help for inline/formula ---

FORMULA Function formula.

FORMULA(FUN) returns the formula for the INLINE object FUN.

See also inline/argnames, inline/char.

Overloaded methods:

fittype/formula

Reference page in Help browser

doc inline/formula

<cha> - Convert INLINE object to character array.

cha not found.

Use the Help browser search field to search the documentation, or

type "help help" for help command options, such as help for methods.

Differential equation solvers

Initial value problem solvers for odEs. (If unsure about stiffness, try ode45

first, then ODE15S.)

<ode45> - Solve non-stiff differential equations, medium order method.

ODE45 Solve non-stiff differential equations, medium order method.

[TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration properties replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components.

ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is

nonsingular. Use ODESET to set the 'Mass' property to a function handle

MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix

is constant, the matrix can be used as the value of the 'Mass' option. If

the mass matrix does not depend on the state variable Y and the function

MASS is to be called with one input argument T, set 'MStateDependence' to

'none'. ODE15S and ODE23T can solve problems with singular mass matrices.

[TOUT,YOUT,TE,YE,IE] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE45(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE45 are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode45(@vdp1,[0 20],[2 0]);

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

solves the system y' = vdp1(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y):

float: double, single

See also

other ODE solvers: ode23, ode113, ode15s, ode23s, ode23t, ode23tb

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: rigidode, ballode, orbitode

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode45, more off

Reference page in Help browser

doc ode45

<ode23> - Solve non-stiff differential equations, low order method.

ODE23 Solve non-stiff differential equations, low order method.

[TOUT,YOUT] = ODE23(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE23(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration properties replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components.

ODE23 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is

nonsingular. Use ODESET to set the 'Mass' property to a function handle

MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix

is constant, the matrix can be used as the value of the 'Mass' option. If

the mass matrix does not depend on the state variable Y and the function

MASS is to be called with one input argument T, set 'MStateDependence' to

'none'. ODE15S and ODE23T can solve problems with singular mass matrices.

[TOUT,YOUT,TE,YE,IE] = ODE23(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE23(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE23 are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode23(@vdp1,[0 20],[2 0]);

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

solves the system y' = vdp1(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y):

float: double, single

See also

other ODE solvers: ode45, ode113, ode15s, ode23s, ode23t, ode23tb

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: rigidode, ballode, orbitode

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode23, more off

Reference page in Help browser

doc ode23

<ode113> - Solve non-stiff differential equations, variable order method.

ODE113 Solve non-stiff differential equations, variable order method.

[TOUT,YOUT] = ODE113(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE113(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration properties replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components.

ODE113 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is

nonsingular. Use ODESET to set the 'Mass' property to a function handle

MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix

is constant, the matrix can be used as the value of the 'Mass' option. If

the mass matrix does not depend on the state variable Y and the function

MASS is to be called with one input argument T, set 'MStateDependence' to

'none'. ODE15S and ODE23T can solve problems with singular mass matrices.

[TOUT,YOUT,TE,YE,IE] = ODE113(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE113(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE113 are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode113(@vdp1,[0 20],[2 0]);

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

solves the system y' = vdp1(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y):

float: double, single

See also

other ODE solvers: ode45, ode23, ode15s, ode23s, ode23t, ode23tb

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: rigidode, ballode, orbitode

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode113, more off

Reference page in Help browser

doc ode113

<ode23t> - Solve moderately stiff ODEs and DAEs Index 1, trapezoidal rule.

ODE23T Solve moderately stiff ODEs and DAEs, trapezoidal rule.

[TOUT,YOUT] = ODE23T(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE23T(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration parameters replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components. The 'NonNegative' property is ignored for problems

where there is a mass matrix.

The Jacobian matrix df/dy is critical to reliability and efficiency. Use

ODESET to set 'Jacobian' to a function handle FJAC if FJAC(T,Y) returns

the Jacobian df/dy or to the matrix df/dy if the Jacobian is constant.

If the 'Jacobian' option is not set (the default), df/dy is approximated

by finite differences. Set 'Vectorized' 'on' if the ODE function is coded

so that ODEFUN(T,[Y1 Y2 ...]) returns [ODEFUN(T,Y1) ODEFUN(T,Y2) ...].

If df/dy is a sparse matrix, set 'JPattern' to the sparsity pattern of

df/dy, i.e., a sparse matrix S with S(i,j) = 1 if component i of f(t,y)

depends on component j of y, and 0 otherwise.

ODE23T can solve problems M(t,y)*y' = f(t,y) with mass matrix M(t,y). Use

ODESET to set the 'Mass' property to a function handle MASS if MASS(T,Y)

returns the value of the mass matrix. If the mass matrix is constant,

the matrix can be used as the value of the 'Mass' option. Problems with

state-dependent mass matrices are more difficult. If the mass matrix does

not depend on the state variable Y and the function MASS is to be called

with one input argument T, set 'MStateDependence' to 'none'. If the mass

matrix depends weakly on Y, set 'MStateDependence' to 'weak' (the

default) and otherwise, to 'strong'. In either case the function MASS is

to be called with the two arguments (T,Y). If there are many differential

equations, it is important to exploit sparsity: Return a sparse

M(t,y). Either supply the sparsity pattern of df/dy using the 'JPattern'

property or a sparse df/dy using the Jacobian property. For strongly

state-dependent M(t,y), set 'MvPattern' to a sparse matrix S with S(i,j)

= 1 if for any k, the (i,k) component of M(t,y) depends on component j of

y, and 0 otherwise.

If the mass matrix is non-singular, the solution of the problem is

straightforward. See examples FEM1ODE, FEM2ODE, BATONODE, or

BURGERSODE. If M(t0,y0) is singular, the problem is a differential-

algebraic equation (DAE). ODE23T solves DAEs of index 1. DAEs have

solutions only when y0 is consistent, i.e., there is a yp0 such that

M(t0,y0)*yp0 = f(t0,y0). Use ODESET to set 'MassSingular' to 'yes', 'no',

or 'maybe'. The default of 'maybe' causes ODE23T to test whether M(t0,y0)

is singular. You can provide yp0 as the value of the 'InitialSlope'

property. The default is the zero vector. If y0 and yp0 are not

consistent, ODE23T treats them as guesses, tries to compute consistent

values close to the guesses, and then goes on to solve the problem. See

examples HB1DAE or AMP1DAE.

[TOUT,YOUT,TE,YE,IE] = ODE23T(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE23T(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE23T are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode23t(@vdp1000,[0 3000],[2 0]);

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

solves the system y' = vdp1000(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

See also

other ODE solvers: ode15s, ode23s, ode23tb, ode45, ode23, ode113

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: vdpode, fem1ode, brussode, hb1dae

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode23t, more off

Reference page in Help browser

doc ode23t

<ode15s> - Solve stiff ODEs and DAEs Index 1, variable order method.

ODE15S Solve stiff differential equations and DAEs, variable order method.

[TOUT,YOUT] = ODE15S(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE15S(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration properties replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components. The 'NonNegative' property is ignored for problems

where there is a mass matrix.

The Jacobian matrix df/dy is critical to reliability and efficiency. Use

ODESET to set 'Jacobian' to a function handle FJAC if FJAC(T,Y) returns

the Jacobian df/dy or to the matrix df/dy if the Jacobian is constant.

If the 'Jacobian' option is not set (the default), df/dy is approximated

by finite differences. Set 'Vectorized' 'on' if the ODE function is coded

so that ODEFUN(T,[Y1 Y2 ...]) returns [ODEFUN(T,Y1) ODEFUN(T,Y2) ...].

If df/dy is a sparse matrix, set 'JPattern' to the sparsity pattern of

df/dy, i.e., a sparse matrix S with S(i,j) = 1 if component i of f(t,y)

depends on component j of y, and 0 otherwise.

ODE15S can solve problems M(t,y)*y' = f(t,y) with mass matrix M(t,y). Use

ODESET to set the 'Mass' property to a function handle MASS if MASS(T,Y)

returns the value of the mass matrix. If the mass matrix is constant,

the matrix can be used as the value of the 'Mass' option. Problems with

state-dependent mass matrices are more difficult. If the mass matrix does

not depend on the state variable Y and the function MASS is to be called

with one input argument T, set 'MStateDependence' to 'none'. If the mass

matrix depends weakly on Y, set 'MStateDependence' to 'weak' (the

default) and otherwise, to 'strong'. In either case the function MASS is

to be called with the two arguments (T,Y). If there are many differential

equations, it is important to exploit sparsity: Return a sparse

M(t,y). Either supply the sparsity pattern of df/dy using the 'JPattern'

property or a sparse df/dy using the Jacobian property. For strongly

state-dependent M(t,y), set 'MvPattern' to a sparse matrix S with S(i,j)

= 1 if for any k, the (i,k) component of M(t,y) depends on component j of

y, and 0 otherwise.

If the mass matrix is non-singular, the solution of the problem is

straightforward. See examples FEM1ODE, FEM2ODE, BATONODE, or

BURGERSODE. If M(t0,y0) is singular, the problem is a differential-

algebraic equation (DAE). ODE15S solves DAEs of index 1. DAEs have

solutions only when y0 is consistent, i.e., there is a yp0 such that

M(t0,y0)*yp0 = f(t0,y0). Use ODESET to set 'MassSingular' to 'yes', 'no',

or 'maybe'. The default of 'maybe' causes ODE15S to test whether M(t0,y0)

is singular. You can provide yp0 as the value of the 'InitialSlope'

property. The default is the zero vector. If y0 and yp0 are not

consistent, ODE15S treats them as guesses, tries to compute consistent

values close to the guesses, and then goes on to solve the problem. See

examples HB1DAE or AMP1DAE.

[TOUT,YOUT,TE,YE,IE] = ODE15S(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE15S(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE15S are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode15s(@vdp1000,[0 3000],[2 0]);

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

solves the system y' = vdp1000(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

See also

other ODE solvers: ode23s, ode23t, ode23tb, ode45, ode23, ode113

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: vdpode, fem1ode, brussode, hb1dae

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode15s, more off

Reference page in Help browser

doc ode15s

<ode23s> - Solve stiff differential equations, low order method.

ODE23S Solve stiff differential equations, low order method.

[TOUT,YOUT] = ODE23S(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE23S(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration properties replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

The Jacobian matrix df/dy is critical to reliability and efficiency. Use

ODESET to set 'Jacobian' to a function handle FJAC if FJAC(T,Y) returns

the Jacobian df/dy or to the matrix df/dy if the Jacobian is constant.

If the 'Jacobian' option is not set (the default), df/dy is approximated

by finite differences. Set 'Vectorized' 'on' if the ODE function is coded

so that ODEFUN(T,[Y1 Y2 ...]) returns [ODEFUN(T,Y1) ODEFUN(T,Y2) ...].

If df/dy is a sparse matrix, set 'JPattern' to the sparsity pattern of

df/dy, i.e., a sparse matrix S with S(i,j) = 1 if component i of f(t,y)

depends on component j of y, and 0 otherwise.

ODE23S can solve problems M*y' = f(t,y) with a constant mass matrix M

that is nonsingular. Use ODESET to set the 'Mass' property to the mass

matrix. If there are many differential equations, it is important to

exploit sparsity: Use a sparse M. Either supply the sparsity pattern of

df/dy using the 'JPattern' property or a sparse df/dy using the Jacobian

property. ODE15S and ODE23T can solve problems with singular mass

matrices.

[TOUT,YOUT,TE,YE,IE] = ODE23S(ODEFUN,TSPAN,Y0,OPTIONS...) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE23S(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE23S are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode23s(@vdp1000,[0 3000],[2 0]);

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

solves the system y' = vdp1000(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

See also

other ODE solvers: ode15s, ode23t, ode23tb, ode45, ode23, ode113

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: vdpode, brussode

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode23s, more off

Reference page in Help browser

doc ode23s

<ode23tb> - Solve stiff differential equations, low order method.

ODE23TB Solve stiff differential equations, low order method.

[TOUT,YOUT] = ODE23TB(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates

the system of differential equations y' = f(t,y) from time T0 to TFINAL

with initial conditions Y0. ODEFUN is a function handle. For a scalar T

and a vector Y, ODEFUN(T,Y) must return a column vector corresponding

to f(t,y). Each row in the solution array YOUT corresponds to a time

returned in the column vector TOUT. To obtain solutions at specific

times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =

[T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE23TB(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default

integration parameters replaced by values in OPTIONS, an argument created

with the ODESET function. See ODESET for details. Commonly used options

are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector

of absolute error tolerances 'AbsTol' (all components 1e-6 by default).

If certain components of the solution must be non-negative, use

ODESET to set the 'NonNegative' property to the indices of these

components. The 'NonNegative' property is ignored for problems

where there is a mass matrix.

The Jacobian matrix df/dy is critical to reliability and efficiency. Use

ODESET to set 'Jacobian' to a function handle FJAC if FJAC(T,Y) returns

the Jacobian df/dy or to the matrix df/dy if the Jacobian is constant.

If the 'Jacobian'option is not set (the default), df/dy is approximated

by finite differences. Set 'Vectorized' 'on' if the ODE function is coded

so that ODEFUN(T,[Y1 Y2 ...]) returns [ODEFUN(T,Y1) ODEFUN(T,Y2) ...].

If df/dy is a sparse matrix, set 'JPattern' to the sparsity pattern of

df/dy, i.e., a sparse matrix S with S(i,j) = 1 if component i of f(t,y)

depends on component j of y, and 0 otherwise.

ODE23TB can solve problems M(t,y)*y' = f(t,y) with mass matrix M(t,y)

that is nonsingular. Use ODESET to set the 'Mass' property to a function

handle MASS if MASS(T,Y) returns the value of the mass matrix. If the mass

matrix is constant, the matrix can be used as the value of the 'Mass'

option. Problems with state-dependent mass matrices are more

difficult. If the mass matrix does not depend on the state variable Y and

the function MASS is to be called with one input argument T, set

'MStateDependence' to 'none'. If the mass matrix depends weakly on Y, set

'MStateDependence' to 'weak' (the default) and otherwise, to 'strong'. In

either case the function MASS is to be called with the two arguments

(T,Y). If there are many differential equations, it is important to

exploit sparsity: Return a sparse M(t,y). Either supply the sparsity

pattern of df/dy using the 'JPattern' property or a sparse df/dy using

the Jacobian property. For strongly state-dependent M(t,y), set

'MvPattern' to a sparse matrix S with S(i,j) = 1 if for any k, the (i,k)

component of M(t,y) depends on component j of y, and 0 otherwise. ODE15S

and ODE23T can solve problems with singular mass matrices.

[TOUT,YOUT,TE,YE,IE] = ODE23TB(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above

while also finding where functions of (T,Y), called event functions,

are zero. For each function you specify whether the integration is

to terminate at a zero and whether the direction of the zero crossing

matters. These are the three column vectors returned by EVENTS:

[VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function:

VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration

is to terminate at a zero of this event function and 0 otherwise.

DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only

zeros where the event function is increasing, and -1 if only zeros where

the event function is decreasing. Output TE is a column vector of times

at which events occur. Rows of YE are the corresponding solutions, and

indices in vector IE specify which event occurred.

SOL = ODE23TB(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be

used with DEVAL to evaluate the solution or its first derivative at

any point between T0 and TFINAL. The steps chosen by ODE23TB are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

[t,y]=ode23tb(@vdp1000,[0 3000],[2 0]);

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

solves the system y' = vdp1000(t,y), using the default relative error

tolerance 1e-3 and the default absolute tolerance of 1e-6 for each

component, and plots the first component of the solution.

See also

other ODE solvers: ode15s, ode23s, ode23t, ode45, ode23, ode113

implicit ODEs: ode15i

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: vdpode, fem1ode, brussode

function handles: function_handle

NOTE:

The interpretation of the first input argument of the ODE solvers and

some properties available through ODESET have changed in MATLAB 6.0.

Although we still support the v5 syntax, any new functionality is

available only with the new syntax. To see the v5 help, type in

the command line

more on, type ode23tb, more off

Reference page in Help browser

doc ode23tb

Initial value problem solver for fully implicit ODEs/DAEs F(t,y,y')=0

<decic> - Compute consistent initial conditions.

DECIC Compute consistent initial conditions for ODE15I.

[Y0MOD,YP0MOD] = DECIC(ODEFUN,T0,Y0,FIXED_Y0,YP0,FIXED_YP0) uses the input

Y0,YP0 as initial guesses for an iteration to find output values such

that ODEFUN(T0,Y0MOD,YP0MOD) = 0. ODEFUN is a function handle. T0 is

a scalar, Y0 and YP0 are column vectors. FIXED_Y0 and FIXED_YP0 are vectors

of zeros and ones. DECIC changes as few components of the guess as possible.

You can specify that certain components are to be held fixed by setting

FIXED_Y0(i) = 1 if no change is permitted in the guess for Y0(i) and 0

otherwise. An empty array for FIXED_Y0 is interpreted as allowing changes

in all entries. FIXED_YP0 is handled similarly.

You cannot fix more than length(Y0) components. Depending on the problem,

it may not be possible to fix this many. It also may not be possible to

fix certain components of Y0 or YP0. It is recommended that you fix no

more components than necessary.

[Y0MOD,YP0MOD] = DECIC(ODEFUN,T0,Y0,FIXED_Y0,YP0,FIXED_YP0,OPTIONS)

computes as above with default values of integration tolerances replaced

by the values in OPTIONS, a structure created with the ODESET function.

[Y0MOD,YP0MOD,RESNRM] = DECIC(ODEFUN,T0,Y0,FIXED_Y0,YP0,FIXED_YP0...)

returns the norm of ODEFUN(T0,Y0MOD,YP0MOD) as RESNRM. If the norm

seems unduly large, use OPTIONS to specify smaller RelTol (1e-3 by default).

See also ode15i, odeset, ihb1dae, iburgersode, function_handle.

Reference page in Help browser

doc decic

<ode15i> - Solve implicit ODEs or DAEs Index 1.

ODE15I Solve fully implicit differential equations, variable order method.

[TOUT,YOUT] = ODE15I(ODEFUN,TSPAN,Y0,YP0) with TSPAN = [T0 TFINAL]

integrates the system of differential equations f(t,y,y') = 0 from time

T0 to TFINAL, with initial conditions Y0,YP0. Function ODE15I solves ODEs

and DAEs of index 1. The initial conditions must be "consistent", meaning

that f(T0,Y0,YP0)=0. Use the function DECIC to compute consistent initial

conditions close to guessed values. ODEFUN is a function handle. For a

scalar T and vectors Y and YP, ODEFUN(T,Y,YP) must return a column vector

corresponding to f(t,y,y'). Each row in the solution array YOUT

corresponds to a time returned in the column vector TOUT. To obtain

solutions at specific times T0,T1,...,TFINAL (all increasing or all

decreasing), use TSPAN = [T0 T1 ... TFINAL].

[TOUT,YOUT] = ODE15I(ODEFUN,TSPAN,Y0,YP0,OPTIONS) solves as above with

default integration properties replaced by values in OPTIONS, an argument

created with the ODESET function. See ODESET for details. Commonly used

options are scalar relative error tolerance 'RelTol' (1e-3 by default)

and vector of absolute error tolerances 'AbsTol' (all components 1e-6

by default).

The Jacobian matrices df/dy and df/dy' are critical to reliability and

efficiency. Use ODESET to set 'Jacobian' to a function handle FJAC if

[DFDY,DFDYP] = FJAC(T,Y,YP) returns the matrices df/dy and df/dy'.

If DFDY = [], df/dy is approximated by finite differences and similarly

for DFDYP. If the 'Jacobian' option is not set (the default), both

matrices are approximated by finite differences.

Set 'Vectorized' {'on','off'} if the ODE function is coded so that

ODEFUN(T,[Y1 Y2 ...],YP) returns [ODEFUN(T,Y1,YP) ODEFUN(T,Y2,YP) ...].

Set 'Vectorized' {'off','on'} if the ODE function is coded so that

ODEFUN(T,Y,[YP1 YP2 ...]) returns [ODEFUN(T,Y,YP1) ODEFUN(T,Y,YP2) ...].

If df/dy or df/dy' is a sparse matrix, set 'JPattern' to the sparsity

patterns, {SPDY,SPDYP}. A sparsity pattern of df/dy is a sparse

matrix SPDY with SPDY(i,j) = 1 if component i of f(t,y,yp)

depends on component j of y, and 0 otherwise. Use SPDY = [] to

indicate that df/dy is a full matrix. Similarly for df/dy' and

SPDYP. The default value of 'JPattern' is {[],[]}.

[TOUT,YOUT,TE,YE,IE] = ODE15I(ODEFUN,TSPAN,Y0,YP0,OPTIONS) with the 'Events'

property in OPTIONS set to a function handle EVENTS, solves as above while

also finding where functions of (T,Y,YP), called event functions, are zero.

For each function you specify whether the integration is to terminate at

a zero and whether the direction of the zero crossing matters. These are

the three column vectors returned by EVENTS: [VALUE,ISTERMINAL,DIRECTION] =

EVENTS(T,Y,YP). For the I-th event function: VALUE(I) is the value of the

function, ISTERMINAL(I)=1 if the integration is to terminate at a zero of

this event function and 0 otherwise. DIRECTION(I)=0 if all zeros are to

be computed (the default), +1 if only zeros where the event function is

increasing, and -1 if only zeros where the event function is

decreasing. Output TE is a column vector of times at which events occur.

Rows of YE are the corresponding solutions, and indices in vector IE

specify which event occurred.

SOL = ODE15I(ODEFUN,[T0 TFINAL],Y0,YP0,...) returns a structure that

can be used with DEVAL to evaluate the solution or its first derivative

at any point between T0 and TFINAL. The steps chosen by ODE15I are returned

in a row vector SOL.x. For each I, the column SOL.y(:,I) contains

the solution at SOL.x(I). If events were detected, SOL.xe is a row vector

of points at which events occurred. Columns of SOL.ye are the corresponding

solutions, and indices in vector SOL.ie specify which event occurred.

Example

t0 = 1;

y0 = sqrt(3/2);

yp0 = 0;

[y0,yp0] = decic(@weissinger,t0,y0,1,yp0,0);

uses a helper function DECIC to hold fixed the initial value for y(t0)

and compute a consistent initial value for y'(t0) for the Weissinger

implicit ODE. The ODE is solved using ODE15I and the numerical solution

is plotted against the analytical solution

[t,y] = ode15i(@weissinger,[1 10],y0,yp0);

ytrue = sqrt(t.^2 + 0.5);

plot(t,y,t,ytrue,'o');

See also

other ODE solvers: ode15s, ode23s, ode23t, ode23tb, ode45, ode23, ode113

initial conditions: decic

options handling: odeset, odeget

output functions: odeplot, odephas2, odephas3, odeprint

evaluating solution: deval

ODE examples: ihb1dae, iburgersode

function handles: function_handle

Reference page in Help browser

doc ode15i

Соседние файлы в папке Библиотеки Matlab