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

matlab\datafun- Анализ данных и преобразование Фурье

Basic operations

<max> - Largest component.

MAX Largest component.

For vectors, MAX(X) is the largest element in X. For matrices,

MAX(X) is a row vector containing the maximum element from each

column. For N-D arrays, MAX(X) operates along the first

non-singleton dimension.

[Y,I] = MAX(X) returns the indices of the maximum values in vector I.

If the values along the first non-singleton dimension contain more

than one maximal element, the index of the first one is returned.

MAX(X,Y) returns an array the same size as X and Y with the

largest elements taken from X or Y. Either one can be a scalar.

[Y,I] = MAX(X,[],DIM) operates along the dimension DIM.

When X is complex, the maximum is computed using the magnitude

MAX(ABS(X)). In the case of equal magnitude elements, then the phase

angle MAX(ANGLE(X)) is used.

NaN's are ignored when computing the maximum. When all elements in X

are NaN's, then the first one is returned as the maximum.

Example: If X = [2 8 4 then max(X,[],1) is [7 8 9],

7 3 9]

max(X,[],2) is [8 and max(X,5) is [5 8 5

9], 7 5 9].

See also min, median, mean, sort.

Overloaded methods:

timeseries/max

codistributed/max

fints/max

localpspline/max

localpoly/max

ordinal/max

Reference page in Help browser

doc max

<min> - Smallest component.

MIN Smallest component.

For vectors, MIN(X) is the smallest element in X. For matrices,

MIN(X) is a row vector containing the minimum element from each

column. For N-D arrays, MIN(X) operates along the first

non-singleton dimension.

[Y,I] = MIN(X) returns the indices of the minimum values in vector I.

If the values along the first non-singleton dimension contain more

than one minimal element, the index of the first one is returned.

MIN(X,Y) returns an array the same size as X and Y with the

smallest elements taken from X or Y. Either one can be a scalar.

[Y,I] = MIN(X,[],DIM) operates along the dimension DIM.

When X is complex, the minimum is computed using the magnitude

MIN(ABS(X)). In the case of equal magnitude elements, then the phase

angle MIN(ANGLE(X)) is used.

NaN's are ignored when computing the minimum. When all elements in X

are NaN's, then the first one is returned as the minimum.

Example: If X = [2 8 4 then min(X,[],1) is [2 3 4],

7 3 9]

min(X,[],2) is [2 and min(X,5) is [2 5 4

3], 5 3 5].

See also max, median, mean, sort.

Overloaded methods:

timeseries/min

codistributed/min

fints/min

localpspline/min

localpoly/min

ordinal/min

Reference page in Help browser

doc min

<mean> - Average or mean value.

MEAN Average or mean value.

For vectors, MEAN(X) is the mean value of the elements in X. For

matrices, MEAN(X) is a row vector containing the mean value of

each column. For N-D arrays, MEAN(X) is the mean value of the

elements along the first non-singleton dimension of X.

MEAN(X,DIM) takes the mean along the dimension DIM of X.

Example: If X = [1 2 3; 3 3 6; 4 6 8; 4 7 7];

then mean(X,1) is [3.0000 4.5000 6.0000] and

mean(X,2) is [2.0000 4.0000 6.0000 6.0000].'

Class support for input X:

float: double, single

See also median, std, min, max, var, cov, mode.

Overloaded methods:

timeseries/mean

fints/mean

sweepset/mean

ProbDistUnivParam/mean

Reference page in Help browser

doc mean

<median> - Median value.

MEDIAN Median value.

For vectors, MEDIAN(a) is the median value of the elements in a.

For matrices, MEDIAN(A) is a row vector containing the median

value of each column. For N-D arrays, MEDIAN(A) is the median

value of the elements along the first non-singleton dimension

of A.

MEDIAN(A,DIM) takes the median along the dimension DIM of A.

Example: If A = [1 2 4 4; 3 4 6 6; 5 6 8 8; 5 6 8 8];

then median(A) is [4 5 7 7] and median(A,2)

is [3 5 7 7].'

Class support for input A:

float: double, single

See also mean, std, min, max, var, cov, mode.

Overloaded methods:

timeseries/median

ProbDistUnivParam/median

ProbDistUnivKernel/median

Reference page in Help browser

doc median

<mode> - Mode, or most frequent value in a sample.

MODE Mode, or most frequent value in a sample.

M=MODE(X) for vector X computes M as the sample mode, or most frequently

occurring value in X. For a matrix X, M is a row vector containing

the mode of each column. For N-D arrays, MODE(X) is the mode of the

elements along the first non-singleton dimension of X.

When there are multiple values occurring equally frequently, MODE

returns the smallest of those values. For complex inputs, this is taken

to be the first value in a sorted list of values.

[M,F]=MODE(X) also returns an array F, of the same size as M.

Each element of F is the number of occurrences of the corresponding

element of M.

[M,F,C]=MODE(X) also returns a cell array C, of the same size

as M. Each element of C is a sorted vector of all the values having

the same frequency as the corresponding element of M.

[...]=MODE(X,DIM) takes the mode along the dimension DIM of X.

This function is most useful with discrete or coarsely rounded data.

The mode for a continuous probability distribution is defined as

the peak of its density function. Applying the MODE function to a

sample from that distribution is unlikely to provide a good estimate

of the peak; it would be better to compute a histogram or density

estimate and calculate the peak of that estimate. Also, the MODE

function is not suitable for finding peaks in distributions having

multiple modes.

Example: If X = [3 3 1 4

0 0 1 1

0 1 2 4]

then mode(X) is [0 0 1 4] and mode(X,2) is [3

0

0]

To find the mode of a continuous variable grouped into bins:

y = randn(1000,1);

edges = -6:.25:6;

[n,bin] = histc(y,edges);

m = mode(bin);

edges([m, m+1])

hist(y,edges+.125)

Class support for input X:

float: double, single

See also mean, median, hist, histc.

Overloaded methods:

timeseries/mode

Reference page in Help browser

doc mode

<std> - Standard deviation.

STD Standard deviation.

For vectors, Y = STD(X) returns the standard deviation. For matrices,

Y is a row vector containing the standard deviation of each column. For

N-D arrays, STD operates along the first non-singleton dimension of X.

STD normalizes Y by (N-1), where N is the sample size. This is the

sqrt of an unbiased estimator of the variance of the population from

which X is drawn, as long as X consists of independent, identically

distributed samples.

Y = STD(X,1) normalizes by N and produces the square root of the second

moment of the sample about its mean. STD(X,0) is the same as STD(X).

Y = STD(X,FLAG,DIM) takes the standard deviation along the dimension

DIM of X. Pass in FLAG==0 to use the default normalization by N-1, or

1 to use N.

Example: If X = [4 -2 1

9 5 7]

then std(X,0,1) is [3.5355 4.9497 4.2426] and std(X,0,2) is [3.0

2.0]

Class support for input X:

float: double, single

See also cov, mean, var, median, corrcoef.

Overloaded methods:

timeseries/std

fints/std

ProbDistUnivParam/std

Reference page in Help browser

doc std

<var> - Variance.

VAR Variance.

For vectors, Y = VAR(X) returns the variance of the values in X. For

matrices, Y is a row vector containing the variance of each column of

X. For N-D arrays, VAR operates along the first non-singleton

dimension of X.

VAR normalizes Y by N-1 if N>1, where N is the sample size. This is

an unbiased estimator of the variance of the population from which X is

drawn, as long as X consists of independent, identically distributed

samples. For N=1, Y is normalized by N.

Y = VAR(X,1) normalizes by N and produces the second moment of the

sample about its mean. VAR(X,0) is the same as VAR(X).

Y = VAR(X,W) computes the variance using the weight vector W. W typically

contains either counts or inverse variances. The length of W must equal

the length of the dimension over which VAR operates, and its elements must

be nonnegative. If X(I) is assumed to have variance proportional to

1/W(I), then Y * MEAN(W)/W(I) is an estimate of the variance of X(I). In

other words, Y * MEAN(W) is an estimate of variance for an observation

given weight 1.

Y = VAR(X,W,DIM) takes the variance along the dimension DIM of X. Pass

in 0 for W to use the default normalization by N-1, or 1 to use N.

The variance is the square of the standard deviation (STD).

Example: If X = [4 -2 1

9 5 7]

then var(X,0,1) is [12.5 24.5 18.0] and var(X,0,2) is [9.0

4.0]

Class support for inputs X, W:

float: double, single

See also mean, std, cov, corrcoef.

Overloaded methods:

timeseries/var

fints/var

xregunispline/var

xregmulti/var

xregmodel/var

xregarx/var

localmulti/var

localavfit/var

ProbDistUnivParam/var

Reference page in Help browser

doc var

<sort> - Sort in ascending order.

SORT Sort in ascending or descending order.

For vectors, SORT(X) sorts the elements of X in ascending order.

For matrices, SORT(X) sorts each column of X in ascending order.

For N-D arrays, SORT(X) sorts the along the first non-singleton

dimension of X. When X is a cell array of strings, SORT(X) sorts

the strings in ASCII dictionary order.

Y = SORT(X,DIM,MODE)

has two optional parameters.

DIM selects a dimension along which to sort.

MODE selects the direction of the sort

'ascend' results in ascending order

'descend' results in descending order

The result is in Y which has the same shape and type as X.

[Y,I] = SORT(X,DIM,MODE) also returns an index matrix I.

If X is a vector, then Y = X(I).

If X is an m-by-n matrix and DIM=1, then

for j = 1:n, Y(:,j) = X(I(:,j),j); end

When X is complex, the elements are sorted by ABS(X). Complex

matches are further sorted by ANGLE(X).

When more than one element has the same value, the order of the

elements are preserved in the sorted result and the indexes of

equal elements will be ascending in any index matrix.

Example: If X = [3 7 5

0 4 2]

then sort(X,1) is [0 4 2 and sort(X,2) is [3 5 7

3 7 5] 0 2 4];

See also issorted, sortrows, min, max, mean, median, unique.

Overloaded methods:

cgprojconnections/sort

xregdesign/sort

sweepset/sort

ordinal/sort

nominal/sort

sym/sort

Reference page in Help browser

doc sort

<sortrows> - Sort rows in ascending order.

SORTROWS Sort rows in ascending order.

Y = SORTROWS(X) sorts the rows of the matrix X in ascending order as a

group. X is a 2-D numeric or char matrix. For a char matrix containing

strings in each row, this is the familiar dictionary sort. When X is

complex, the elements are sorted by ABS(X). Complex matches are further

sorted by ANGLE(X). X can be any numeric or char class. Y is the same

size and class as X.

SORTROWS(X,COL) sorts the matrix based on the columns specified in the

vector COL. If an element of COL is positive, the corresponding column

in X will be sorted in ascending order; if an element of COL is negative,

the corresponding column in X will be sorted in descending order. For

example, SORTROWS(X,[2 -3]) sorts the rows of X first in ascending order

for the second column, and then by descending order for the third

column.

[Y,I] = SORTROWS(X) and [Y,I] = SORTROWS(X,COL) also returns an index

matrix I such that Y = X(I,:).

Notes

-----

SORTROWS uses a stable version of quicksort. NaN values are sorted

as if they are higher than all other values, including +Inf.

Class support for input X:

numeric, logical, char

See also sort, issorted.

Overloaded methods:

ordinal/sortrows

dataset/sortrows

Reference page in Help browser

doc sortrows

<issorted> - TRUE for sorted vector and matrices.

ISSORTED TRUE for sorted vector and matrices.

ISSORTED(X), when X is a vector, returns TRUE if the elements of X

are in sorted order (in other words, if X and SORT(X) are identical)

and FALSE if not. X can be a 1xn or nx1 cell array of strings.

For character arrays, ASCII order is used. For cell array of strings,

dictionary order is used.

ISSORTED(X,'rows'), when X is a matrix, returns TRUE if the rows of X

are in sorted order (if X and SORTROWS(X) are identical) and FALSE if not.

ISSORTED(X,'rows') does not support cell array of strings.

See also sort, sortrows, unique, ismember, intersect, setdiff, setxor, union.

Overloaded methods:

fints/issorted

ordinal/issorted

Reference page in Help browser

doc issorted

<sum> - Sum of elements.

SUM Sum of elements.

S = SUM(X) is the sum of the elements of the vector X. If

X is a matrix, S is a row vector with the sum over each

column. For N-D arrays, SUM(X) operates along the first

non-singleton dimension.

If X is floating point, that is double or single, S is

accumulated natively, that is in the same class as X,

and S has the same class as X. If X is not floating point,

S is accumulated in double and S has class double.

S = SUM(X,DIM) sums along the dimension DIM.

S = SUM(X,'double') and S = SUM(X,DIM,'double') accumulate

S in double and S has class double, even if X is single.

S = SUM(X,'native') and S = SUM(X,DIM,'native') accumulate

S natively and S has the same class as X.

Examples:

If X = [0 1 2

3 4 5]

then sum(X,1) is [3 5 7] and sum(X,2) is [ 3

12];

If X = int8(1:20) then sum(X) accumulates in double and the

result is double(210) while sum(X,'native') accumulates in

int8, but overflows and saturates to int8(127).

See also prod, cumsum, diff, accumarray, isfloat.

Overloaded methods:

timeseries/sum

codistributed/sum

umat/sum

ndlft/sum

Reference page in Help browser

doc sum

<prod> - Product of elements.

PROD Product of elements.

For vectors, PROD(X) is the product of the elements of X. For

matrices, PROD(X) is a row vector with the product over each

column. For N-D arrays, PROD(X) operates on the first

non-singleton dimension.

PROD(X,DIM) works along the dimension DIM.

Example: If X = [0 1 2

3 4 5]

then prod(X,1) is [0 4 10] and prod(X,2) is [ 0

60]

See also sum, cumprod, diff.

Overloaded methods:

codistributed/prod

laurpoly/prod

laurmat/prod

Reference page in Help browser

doc prod

<hist> - Histogram.

HIST Histogram.

N = HIST(Y) bins the elements of Y into 10 equally spaced containers

and returns the number of elements in each container. If Y is a

matrix, HIST works down the columns.

N = HIST(Y,M), where M is a scalar, uses M bins.

N = HIST(Y,X), where X is a vector, returns the distribution of Y

among bins with centers specified by X. The first bin includes

data between -inf and the first center and the last bin

includes data between the last bin and inf. Note: Use HISTC if

it is more natural to specify bin edges instead.

[N,X] = HIST(...) also returns the position of the bin centers in X.

HIST(...) without output arguments produces a histogram bar plot of

the results. The bar edges on the first and last bins may extend to

cover the min and max of the data unless a matrix of data is supplied.

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

Class support for inputs Y, X:

float: double, single

See also histc, mode.

Overloaded methods:

fints/hist

categorical/hist

Reference page in Help browser

doc hist

<histc> - Histogram count.

HISTC Histogram count.

N = HISTC(X,EDGES), for vector X, counts the number of values in X

that fall between the elements in the EDGES vector (which must contain

monotonically non-decreasing values). N is a LENGTH(EDGES) vector

containing these counts.

N(k) will count the value X(i) if EDGES(k) <= X(i) < EDGES(k+1). The

last bin will count any values of X that match EDGES(end). Values

outside the values in EDGES are not counted. Use -inf and inf in

EDGES to include all non-NaN values.

For matrices, HISTC(X,EDGES) is a matrix of column histogram counts.

For N-D arrays, HISTC(X,EDGES) operates along the first non-singleton

dimension.

HISTC(X,EDGES,DIM) operates along the dimension DIM.

[N,BIN] = HISTC(X,EDGES,...) also returns an index matrix BIN. If X is a

vector, N(K) = SUM(BIN==K). BIN is zero for out of range values. If X

is an m-by-n matrix, then,

for j=1:n, N(K,j) = SUM(BIN(:,j)==K); end

Use BAR(EDGES,N,'histc') to plot the histogram.

Example:

histc(pascal(3),1:6) produces the array [3 1 1;

0 1 0;

0 1 1;

0 0 0;

0 0 0;

0 0 1]

Class support for inputs X,EDGES:

float: double, single

See also hist.

Reference page in Help browser

doc histc

<trapz> - Trapezoidal numerical integration.

TRAPZ Trapezoidal numerical integration.

Z = TRAPZ(Y) computes an approximation of the integral of Y via

the trapezoidal method (with unit spacing). To compute the integral

for spacing different from one, multiply Z by the spacing increment.

For vectors, TRAPZ(Y) is the integral of Y. For matrices, TRAPZ(Y)

is a row vector with the integral over each column. For N-D

arrays, TRAPZ(Y) works across the first non-singleton dimension.

Z = TRAPZ(X,Y) computes the integral of Y with respect to X using

the trapezoidal method. X and Y must be vectors of the same

length, or X must be a column vector and Y an array whose first

non-singleton dimension is length(X). TRAPZ operates along this

dimension.

Z = TRAPZ(X,Y,DIM) or TRAPZ(Y,DIM) integrates across dimension DIM

of Y. The length of X must be the same as size(Y,DIM)).

Example: If Y = [0 1 2

3 4 5]

then trapz(Y,1) is [1.5 2.5 3.5] and trapz(Y,2) is [2

8];

Class support for inputs X, Y:

float: double, single

See also sum, cumsum, cumtrapz, quad.

Reference page in Help browser

doc trapz

<cumsum> - Cumulative sum of elements.

CUMSUM Cumulative sum of elements.

For vectors, CUMSUM(X) is a vector containing the cumulative sum of

the elements of X. For matrices, CUMSUM(X) is a matrix the same size

as X containing the cumulative sums over each column. For N-D

arrays, CUMSUM(X) operates along the first non-singleton dimension.

CUMSUM(X,DIM) works along the dimension DIM.

Example: If X = [0 1 2

3 4 5]

then cumsum(X,1) is [0 1 2 and cumsum(X,2) is [0 1 3

3 5 7] 3 7 12]

See also cumprod, sum, prod.

Overloaded methods:

codistributed/cumsum

fints/cumsum

Reference page in Help browser

doc cumsum

<cumprod> - Cumulative product of elements.

CUMPROD Cumulative product of elements.

For vectors, CUMPROD(X) is a vector containing the cumulative product

of the elements of X. For matrices, CUMPROD(X) is a matrix the same

size as X containing the cumulative products over each column. For

N-D arrays, CUMPROD(X) operates along the first non-singleton

dimension.

CUMPROD(X,DIM) works along the dimension DIM.

Example: If X = [0 1 2

3 4 5]

then cumprod(X,1) is [0 1 2 and cumprod(X,2) is [0 0 0

0 4 10] 3 12 60]

See also cumsum, sum, prod.

Overloaded methods:

codistributed/cumprod

Reference page in Help browser

doc cumprod

<cumtrapz> - Cumulative trapezoidal numerical integration.

CUMTRAPZ Cumulative trapezoidal numerical integration.

Z = CUMTRAPZ(Y) computes an approximation of the cumulative

integral of Y via the trapezoidal method (with unit spacing). To

compute the integral for spacing different from one, multiply Z by

the spacing increment.

For vectors, CUMTRAPZ(Y) is a vector containing the cumulative

integral of Y. For matrices, CUMTRAPZ(Y) is a matrix the same size as

X with the cumulative integral over each column. For N-D arrays,

CUMTRAPZ(Y) works along the first non-singleton dimension.

Z = CUMTRAPZ(X,Y) computes the cumulative integral of Y with respect

to X using trapezoidal integration. X and Y must be vectors of the

same length, or X must be a column vector and Y an array whose first

non-singleton dimension is length(X). CUMTRAPZ operates across this

dimension.

Z = CUMTRAPZ(X,Y,DIM) or CUMTRAPZ(Y,DIM) integrates along dimension

DIM of Y. The length of X must be the same as size(Y,DIM)).

Example: If Y = [0 1 2

3 4 5]

then cumtrapz(Y,1) is [0 0 0 and cumtrapz(Y,2) is [0 0.5 2

1.5 2.5 3.5] 0 3.5 8];

Class support for inputs X,Y:

float: double, single

See also cumsum, trapz, quad, quadv.

Reference page in Help browser

doc cumtrapz

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