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

matlab\elmat – Элементарные матрицы и матричные операции

Elementary matrices.

<zeros> - Zeros array.

ZEROS Zeros array.

ZEROS(N) is an N-by-N matrix of zeros.

ZEROS(M,N) or ZEROS([M,N]) is an M-by-N matrix of zeros.

ZEROS(M,N,P,...) or ZEROS([M N P ...]) is an M-by-N-by-P-by-... array of

zeros.

ZEROS(SIZE(A)) is the same size as A and all zeros.

ZEROS with no arguments is the scalar 0.

ZEROS(M,N,...,CLASSNAME) or ZEROS([M,N,...],CLASSNAME) is an

M-by-N-by-... array of zeros of class CLASSNAME.

Note: The size inputs M, N, and P... should be nonnegative integers.

Negative integers are treated as 0.

Example:

x = zeros(2,3,'int8');

See also eye, ones.

Overloaded methods:

distributed/zeros

codistributor2dbc/zeros

codistributor1d/zeros

codistributed/zeros

Reference page in Help browser

doc zeros

<ones> - Ones array.

ONES Ones array.

ONES(N) is an N-by-N matrix of ones.

ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones.

ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by-... array of

ones.

ONES(SIZE(A)) is the same size as A and all ones.

ONES with no arguments is the scalar 1.

ONES(M,N,...,CLASSNAME) or ONES([M,N,...],CLASSNAME) is an M-by-N-by-...

array of ones of class CLASSNAME.

Note: The size inputs M, N, and P... should be nonnegative integers.

Negative integers are treated as 0.

Example:

x = ones(2,3,'int8');

See also eye, zeros.

Overloaded methods:

distributed/ones

codistributor2dbc/ones

codistributor1d/ones

codistributed/ones

Reference page in Help browser

doc ones

<eye> - Identity matrix.

EYE Identity matrix.

EYE(N) is the N-by-N identity matrix.

EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on

the diagonal and zeros elsewhere.

EYE(SIZE(A)) is the same size as A.

EYE with no arguments is the scalar 1.

EYE(M,N,CLASSNAME) or EYE([M,N],CLASSNAME) is an M-by-N matrix with 1's

of class CLASSNAME on the diagonal and zeros elsewhere.

Note: The size inputs M and N should be nonnegative integers.

Negative integers are treated as 0.

Example:

x = eye(2,3,'int8');

See also speye, ones, zeros, rand, randn.

Overloaded methods:

distributed/eye

codistributor2dbc/eye

codistributor1d/eye

codistributed/eye

Reference page in Help browser

doc eye

<repmat> - Replicate and tile array.

REPMAT Replicate and tile an array.

B = repmat(A,M,N) creates a large matrix B consisting of an M-by-N

tiling of copies of A. The size of B is [size(A,1)*M, size(A,2)*N].

The statement repmat(A,N) creates an N-by-N tiling.

B = REPMAT(A,[M N]) accomplishes the same result as repmat(A,M,N).

B = REPMAT(A,[M N P ...]) tiles the array A to produce a

multidimensional array B composed of copies of A. The size of B is

[size(A,1)*M, size(A,2)*N, size(A,3)*P, ...].

REPMAT(A,M,N) when A is a scalar is commonly used to produce an M-by-N

matrix filled with A's value and having A's CLASS. For certain values,

you may achieve the same results using other functions. Namely,

REPMAT(NAN,M,N) is the same as NAN(M,N)

REPMAT(SINGLE(INF),M,N) is the same as INF(M,N,'single')

REPMAT(INT8(0),M,N) is the same as ZEROS(M,N,'int8')

REPMAT(UINT32(1),M,N) is the same as ONES(M,N,'uint32')

REPMAT(EPS,M,N) is the same as EPS(ONES(M,N))

Example:

repmat(magic(2), 2, 3)

repmat(uint8(5), 2, 3)

Class support for input A:

float: double, single

See also bsxfun, meshgrid, ones, zeros, nan, inf.

Overloaded methods:

categorical/repmat

uss/repmat

umat/repmat

ndlft/repmat

atom/repmat

Reference page in Help browser

doc repmat

<linspace> - Linearly spaced vector.

LINSPACE Linearly spaced vector.

LINSPACE(X1, X2) generates a row vector of 100 linearly

equally spaced points between X1 and X2.

LINSPACE(X1, X2, N) generates N points between X1 and X2.

For N < 2, LINSPACE returns X2.

Class support for inputs X1,X2:

float: double, single

See also logspace, colon.

Overloaded methods:

cgvalue/linspace

Reference page in Help browser

doc linspace

<logspace> - Logarithmically spaced vector.

LOGSPACE Logarithmically spaced vector.

LOGSPACE(X1, X2) generates a row vector of 50 logarithmically

equally spaced points between decades 10^X1 and 10^X2. If X2

is pi, then the points are between 10^X1 and pi.

LOGSPACE(X1, X2, N) generates N points.

For N < 2, LOGSPACE returns 10^X2.

Class support for inputs X1,X2:

float: double, single

See also linspace, :.

Reference page in Help browser

doc logspace

<freqspace> - Frequency spacing for frequency response.

FREQSPACE Frequency spacing for frequency response.

FREQSPACE returns the implied frequency range for equally spaced

frequency responses. FREQSPACE is useful when creating desired

frequency responses for FSAMP2, FWIND1, and FWIND2 as well as

for various 1-D applications.

[F1,F2] = FREQSPACE(N) returns the 2-D frequency range vectors

F1 and F2 for an N-by-N matrix.

[F1,F2] = FREQSPACE([M N]) returns the 2-D frequency range

Vectors for an m-by-n matrix.

For 2-D vectors and n odd, F = (-1+1/n:2/n:1-1/n).

For 2-D vectors and n even, F = (-1 :2/n:1-2/n).

[F1,F2] = FREQSPACE(...,'meshgrid') is equivalent to

[F1,F2] = freqspace(...); [F1,F2] = meshgrid(F1,F2);

F = FREQSPACE(N) returns the 1-D frequency vector F assuming N

equally spaced points around the unit circle. For 1-D vectors,

F = (0:2/N:1). F = FREQSPACE(N,'whole') returns all N equally

spaced points. In this case, F = (0:2/N:2*(N-1)/N).

Class support for inputs M,N:

float: double, single

See also, in the image Processing Toolbox, fsamp2, fwind1, fwind2.

Reference page in Help browser

doc freqspace

<meshgrid> - X and Y arrays for 3-D plots.

MESHGRID X and Y arrays for 3-D plots.

[X,Y] = MESHGRID(x,y) transforms the domain specified by vectors

X and y into arrays X and y that can be used for the evaluation

of functions of two variables and 3-D surface plots.

The rows of the output array X are copies of the vector x and

the columns of the output array Y are copies of the vector y.

[X,Y] = MESHGRID(x) is an abbreviation for [X,Y] = MESHGRID(x,x).

[X,Y,Z] = MESHGRID(x,y,z) produces 3-D arrays that can be used to

evaluate functions of three variables and 3-D volumetric plots.

For example, to evaluate the function x*exp(-x^2-y^2) over the

range -2 < x < 2, -2 < y < 2,

[X,Y] = meshgrid(-2:.2:2, -2:.2:2);

Z = X .* exp(-X.^2 - Y.^2);

surf(X,Y,Z)

MESHGRID is like NDGRID except that the order of the first two input

and output arguments are switched (i.e., [X,Y,Z] = MESHGRID(x,y,z)

produces the same result as [Y,X,Z] = NDGRID(y,x,z)). Because of

this, MESHGRID is better suited to problems in cartesian space,

while NDGRID is better suited to N-D problems that aren't spatially

based. MESHGRID is also limited to 2-D or 3-D.

Class support for inputs X,Y,Z:

float: double, single

See also surf, slice, ndgrid.

Reference page in Help browser

doc meshgrid

<accumarray> - Construct an array with accumulation.

ACCUMARRAY Construct an array by accumulation.

A = ACCUMARRAY(SUBS,VAL) creates an array A by accumulating elements of the

vector VAL using the subscripts in SUBS. Each row of the M-by-N matrix

SUBS defines an N-dimensional subscript into the output A. Each element of

VAL has a corresponding row in SUBS. ACCUMARRAY collects all elements of

VAL that correspond to identical subscripts in SUBS, sums those values, and

stores the result in the element of A corresponding to the subscript.

Elements of A that are not referred to by any row of SUBS contain zero.

SUBS must contain positive integers. If SUBS is a nonempty matrix with N>1

columns, then A is a N-dimensional array of size MAX(SUBS,[],1). If SUBS is

empty with N>1 columns, then A is an N-dimensional empty array with size

0-by-0-by-...-by-0. SUBS may also be a column vector, and A is then also a

column vector. In this case, A has length MAX(SUBS,[],1) when SUBS is

nonempty, or length zero when SUBS is empty.

SUBS may also be a cell vector with one or more elements, each a vector of

positive integers. All of the vectors must have the same length. In this

case, SUBS is treated as if the vectors formed columns of a subscript matrix.

VAL must be a numeric, logical, or character vector with the same length

as the number of rows in SUBS. VAL may also be a scalar whose value is

repeated for all the rows of SUBS.

ACCUMARRAY sums values from VAL using the default behavior of SUM.

A = ACCUMARRAY(SUBS,VAL,SZ) creates an array A with size SZ, where SZ is a

vector of positive integers. If SUBS is nonempty with N>1 columns, then SZ

must have N elements, where ALL(SZ >= MAX(SUBS,[],1)). If SUBS is a nonempty

column vector, then SZ must be [M 1] where M >= MAX(SUBS). Specify SZ as

[] for the default behavior.

A = ACCUMARRAY(SUBS,VAL,SZ,FUN) applies the function FUN to each subset of

elements of VAL. FUN is a function that accepts a column vector and returns

a numeric, logical, or char scalar, or a scalar cell. A has the same class

as the values returned by FUN. FUN is @SUM by default. Specify FUN as []

for the default behavior.

Note: If the subscripts in SUBS are not sorted, FUN should not depend on the

order of the values in its input data.

A = ACCUMARRAY(SUBS,VAL,SZ,FUN,FILLVAL) puts the scalar value FILLVAL in

elements of A that are not referred to by any row of SUBS. For example, if

SUBS is empty, then A is REPMAT(FILLVAL,SZ). FILLVAL and the values returned

by FUN must have the same class.

A = ACCUMARRAY(SUBS,VAL,SZ,FUN,FILLVAL,ISSPARSE) creates an array A that is

sparse if the logical scalar ISSPARSE is true, or full if ISSPARSE is false.

A is full by default. FILLVAL must be zero or [] if ISSPARSE is true. VAL

and the output of FUN must be double if ISSPARSE is true.

Examples:

Create a 5-by-1 vector, summing values for repeated 1-D subscripts:

subs = [1; 2; 4; 2; 4];

A = accumarray(subs, 101:105)

Create a 2-by-3-by-2 array, summing values for repeated 3-D subscripts:

subs = [1 1 1; 2 1 2; 2 3 2; 2 1 2; 2 3 2];

A = accumarray(subs, 101:105)

Create a 2-by-3-by-2 array, summing values natively:

subs = [1 1 1; 2 1 2; 2 3 2; 2 1 2; 2 3 2];

A = accumarray(subs, int8(101:105), [], @(x) sum(x,'native'))

class(A)

Create an array using MAX, and fill empty elements with NaN:

subs = [1 1; 2 1; 2 3; 2 1; 2 3];

A = accumarray(subs, 101:105, [2 4], @max, NaN)

Create a sparse matrix using PROD:

subs = [1 1; 2 1; 2 3; 2 1; 2 3];

A = accumarray(subs, 101:105, [2 4], @prod, 0, true)

Count the number of subscripts for each bin:

subs = [1 1; 2 1; 2 3; 2 1; 2 3];

A = accumarray(subs, 1, [2 4])

Create a logical array indicating bins with two or more values:

subs = [1 1; 2 1; 2 3; 2 1; 2 3];

A = accumarray(subs, 101:105, [2 4], @(x) length(x)>1)

Group values in a cell array:

subs = [1 1; 2 1; 2 3; 2 1; 2 3];

A = accumarray(subs, 101:105, [2 4], @(x) {x})

A{2}

See also full, sparse, sum, function_handle.

Reference page in Help browser

doc accumarray

<: > - Regularly spaced vector and index into matrix.

Operators and special characters.

Arithmetic operators.

plus - Plus +

uplus - Unary plus +

minus - Minus -

uminus - Unary minus -

mtimes - Matrix multiply *

times - Array multiply .*

mpower - Matrix power ^

power - Array power .^

mldivide - Backslash or left matrix divide \

mrdivide - Slash or right matrix divide /

ldivide - Left array divide .\

rdivide - Right array divide ./

Соседние файлы в папке Библиотеки Matlab