help norm

advertisement
MATLAB HELP
>> help plot
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, disconnected
line objects are created and plotted as discrete points vertically at X.
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b
blue
g
green
r
red
c
cyan
m
.
point
o
x
circle
x-mark
+
magenta
plus
*
star
y
yellow
s
square
k
black
d
diamond
w
white
v
-
solid
:
dotted
-. dashdot
-- dashed
(none) no line
triangle (down)
^
triangle (up)
<
triangle (left)
>
triangle (right)
p
pentagram
h
hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
>> help fplot
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)]
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)
>> help mesh
MESH 3-D mesh surface.
MESH(X,Y,Z,C) plots the colored parametric mesh defined by
four matrix arguments. The view point is specified by VIEW.
The axis labels are determined by the range of X, Y and Z,
or by the current setting of AXIS. The color scaling is determined
by the range of C, or by the current setting of CAXIS. The scaled
color values are used as indices into the current COLORMAP.
MESH(X,Y,Z) uses C = Z, so color is proportional to mesh height.
>> help norm
NORM Matrix or vector norm.
1. For matrices...
NORM(X) is the largest singular value of X, max(svd(X)).
NORM(X,2) is the same as NORM(X).
NORM(X,1) is the 1-norm of X, the largest column sum,
= max(sum(abs(X))).
NORM(X,inf) is the infinity norm of X, the largest row sum,
= max(sum(abs(X'))).
NORM(X,'fro') is the Frobenius norm, sqrt(sum(diag(X'*X))).
2. For vectors...
NORM(V,P) = sum(abs(V).^P)^(1/P).
NORM(V) = norm(V,2).
NORM(V,inf) = max(abs(V)).
>> help fzero
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,FVAL]= FZERO(FUN,...) returns the value of the function described
in FUN, at X.
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.
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 also be an anonymous function:
X = fzero(@(x) sin(3*x),2)
>> help fminbnd
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,FVAL] = FMINBND(...) also returns the value of the objective function,
FVAL, computed in FUN, at X.
Examples
FUN can be specified using @:
X = fminbnd(@cos,3,4)
computes pi to a few decimal places and gives a message upon termination.
FUN can also be an anonymous function:
x = fminbnd(@(x) sin(x)+3,2,5)
>> help fminsearch
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,FVAL]= FMINSEARCH(...) returns the value of the objective function,
described in FUN, at X.
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.
function f = myfun(x,c)
f = x(1)^2 + c*x(2)^2;
To optimize for a specific value of c, first assign the value to c. Then
create a one-argument anonymous function that captures that value of c
and calls myfun with two arguments. Finally, pass this anonymous function
to FMINSEARCH:
c = 1.5; % define parameter first
x = fminsearch(@(x) myfun(x,c),[0.3;1])
FMINSEARCH uses the Nelder-Mead simplex (direct search) method.
>>>> help polyfit
POLYFIT Fit polynomial to data.
P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of
degree N that fits the data Y best in a least-squares sense. P is a
row vector of length N+1 containing the polynomial coefficients in
descending powers, P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1).
[P,S] = POLYFIT(X,Y,N) returns the polynomial coefficients P and a
structure S for use with POLYVAL to obtain error estimates for
predictions. S contains fields for the triangular factor (R) from a QR
decomposition of the Vandermonde matrix of X, the degrees of freedom
(df), and the norm of the residuals (normr). If the data Y are random,
an estimate of the covariance matrix of P is (Rinv*Rinv')*normr^2/df,
where Rinv is the inverse of R.
>> help polyval
POLYVAL Evaluate polynomial.
Y = POLYVAL(P,X) returns the value of a polynomial P evaluated at X. P
is a vector of length N+1 whose elements are the coefficients of the
polynomial in descending powers.
Y = P(1)*X^N + P(2)*X^(N-1) + ... + P(N)*X + P(N+1)
If X is a matrix or vector, the polynomial is evaluated at all
points in X. See POLYVALM for evaluation in a matrix sense.
>> help ode23
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].
>> help ode45
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].
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.
>>
Download