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

matlab\datatypes – Типы данных и структуры

Data types (classes)

<double> - Convert to double precision.

DOUBLE Convert to double precision.

DOUBLE(X) returns the double precision value for X.

If X is already a double precision array, DOUBLE has

no effect.

DOUBLE is called for the expressions in FOR, IF, and WHILE loops

if the expression isn't already double precision. DOUBLE should

be overloaded for all objects where it makes sense to convert it

into a double precision value.

See also single, datatypes, isfloat, isnumeric.

Overloaded methods:

opaque/double

codistributed/double

mfilt.double

xregpointer/double

xregusermod/double

xregunispline/double

xregtwostage/double

xregnnet/double

xregmultilin/double

xregmodel/double

xreglolimot/double

xreglinear/double

xregcovariance/double

xregarx/double

localusermod/double

localtruncps/double

localsurface/double

localpspline/double

localmulti/double

localbspline/double

localavfit/double

sweepsetfilter/double

sweepset/double

cvtest/double

cvdata/double

rptcp/double

rptsp/double

filtstates.double

dfilt.double

dataset/double

categorical/double

Reference page in Help browser

doc double

<logical> - Convert numeric values to logical.

LOGICAL Convert numeric values to logical.

LOGICAL(X) converts the elements of the array X into logicals,

thus returning an array that can be used for logical indexing

or logical tests. logicals can have the values 0 and 1 corresponding

to false and true, respectively. Any non-zero real element of input

array X is converted to a logical 1 while zeros in X become logical 0.

Complex values and NaNs cannot be converted to logicals and will

result in a conversion error. logical arrays can also be created

using the creation functions TRUE and FALSE.

Because logical arrays are returned by the logical operators (&,|,~)

and the relational operators (==,~=,<,<=,>=,>), as well as by

functions like ANY, ALL, ISNAN, ISINF, ISFINITE, ISEMPTY, ISEQUAL,

etc., it is unusual to need to invoke the LOGICAL function itself.

The term "logical indexing" refers to any indexing operation where

the index expression is a logical array, in which case the index is

treated as a mask that selects elements from the indexed array. In

essence, it is a short-hand notation for A(FIND(B)) that enables us

to simply write A(B) when B is a logical array. The result is the

elements of A at the indices where B is one. It is often convenient

to derive the index expression from the indexed data itself. For

example, the positive elements of a vector A can be obtained using

A(A>0).

Logicals can be combined with doubles in arithmetic operations and

will produce results that are of type double. You can convert a

logical to any other numeric data type using the appropriate

conversion function. For example, double(A) converts the logical

array A into a double array.

See also islogical, false, true, relop, ops.

Overloaded methods:

codistributed/logical

Xregpointer/logical

Reference page in Help browser

doc logical

<cell> - Create cell array.

CELL Create cell array.

CELL(N) is an N-by-N cell array of empty matrices.

CELL(M,N) or CELL([M,N]) is an M-by-N cell array of empty

matrices.

CELL(M,N,P,...) or CELL([M N P ...]) is an M-by-N-by-P-by-...

cell array of empty matrices.

CELL(SIZE(A)) is a cell array the same size as A containing

all empty matrices.

See also ones, zeros, struct, deal, paren.

Overloaded methods:

distributed/cell

codistributor2dbc/cell

codistributor1d/cell

codistributed/cell

sweepset/cell

Reference page in Help browser

doc cell

<struct> - Create or convert to structure array.

STRUCT Create or convert to structure array.

S = STRUCT('field1',VALUES1,'field2',VALUES2,...) creates a

structure array with the specified fields and values. The value

arrays VALUES1, VALUES2, etc. must be cell arrays of the same

size, scalar cells or single values. Corresponding elements of the

Value arrays are placed into corresponding structure array elements.

The size of the resulting structure is the same size as the value

cell arrays or 1-by-1 if none of the values is a cell.

STRUCT(OBJ) converts the object OBJ into its equivalent

structure. The class information is lost.

STRUCT([]) creates an empty structure.

To create fields that contain cell arrays, place the cell arrays

within a VALUE cell array. For instance,

s = struct('strings',{{'hello','yes'}},'lengths',[5 3])

creates the 1-by-1 structure

s =

strings: {'hello' 'yes'}

lengths: [5 3]

Example

s = struct('type',{'big','little'},'color','red','x',{3 4})

See also isstruct, setfield, getfield, fieldnames, orderfields,

Isfield, rmfield, deal, substruct, struct2cell, cell2struct.

Overloaded methods:

memmapfile/struct

network/struct

SimData/struct

Reference page in Help browser

doc struct

<single> - Convert to single precision.

SINGLE Convert to single precision.

Y = SINGLE(X) converts the vector X to single precision. X can be any

numeric object (such as a DOUBLE). If X is already single precision,

SINGLE has no effect. Single precision quantities require less storage

than double precision quantities, but have less precision and a

smaller range. REALMAX('single') gives the uper bound for SINGLE while

REALMIN('single') is the smallest positive normalized SINGLE value.

Most operations that are defined on DOUBLE arrays are also defined for

SINGLE arrays. When SINGLE and DOUBLE arrays interact in arithmetic,

the type of the result is SINGLE.

You can define or overload your own methods for the SINGLE class (as you

can for any object) by placing the appropriately named method in an @single

directory within a directory on your path.

See DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large SINGLE array is:

S = zeros(1000,1000,'single')

which creates a 1000x1000 element SINGLE array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = pi * ones(5,6,'single')

See also double, datatypes, uint8, uint16, uint32, uint64, int8, int16,

int32, int64, realmin, realmax, eye, ones, zeros, isfloat, isnumeric.

Overloaded methods:

codistributed/single

dataset/single

categorical/single

Reference page in Help browser

doc single

<uint8> - Convert to unsigned 8-bit integer.

UINT8 Convert to unsigned 8-bit integer.

I = UINT8(X) converts the elements of the array X into unsigned 8-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of a UINT8 range from 0 to 255, or INTMIN('uint8') to INTMAX('uint8').

Values outside this range saturate on overflow, namely they are mapped

to 0 or 255 if they are outside the range. If X is already an unsigned

8-bit integer array, then UINT8 has no effect. DOUBLE and SINGLE values

are rounded to the nearest UINT8 value on conversion.

Some arithmetic operations are defined for UINT8 on interaction with

other UINT8 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

UINT8 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is UINT8.

UINT8 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the UINT8 class (as you

can for any object) by placing the appropriately named method in an

@uint8 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large UINT8 arrays is:

I = zeros(1000,1000,'uint8')

which creates a 1000x1000 element UINT8 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'uint8')

See also double, single, datatypes, isinteger, uint16, uint32, uint64,

int8, int16, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/uint8

categorical/uint8

Reference page in Help browser

doc uint8

<uint16> - Convert to unsigned 16-bit integer.

UINT16 Convert to unsigned 16-bit integer.

I = UINT16(X) converts the elements of the array X into unsigned 16-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of a UINT16 range from 0 to 65535, or INTMIN('uint16') to INTMAX('uint16').

Values outside this range saturate on overflow, namely they are mapped

to 0 or 65535 if they are outside the range. If X is already an unsigned

16-bit integer array, then UINT16 has no effect. DOUBLE and SINGLE values

are rounded to the nearest UINT16 value on conversion.

Some arithmetic operations are defined for UINT16 on interaction with

other UINT16 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

UINT16 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is UINT16.

UINT16 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the UINT16 class (as you

can for any object) by placing the appropriately named method in an

@uint16 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large UINT16 arrays is:

I = zeros(1000,1000,'uint16')

which creates a 1000x1000 element UINT16 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'uint16')

See also double, single, datatypes, isinteger, uint8, uint32, uint64, int8,

int16, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/uint16

categorical/uint16

Reference page in Help browser

doc uint16

<uint32> - Convert to unsigned 32-bit integer.

UINT32 Convert to unsigned 32-bit integer.

I = UINT32(X) converts the elements of the array X into unsigned 32-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of a UINT32 range from 0 to 4,294,967,295, or INTMIN('uint32') to

INTMAX('uint32'). Values outside this range saturate on overflow, namely

they are mapped to 0 or 4,294,967,295 if they are outside the range. If X

is already an unsigned 32-bit integer array, then UINT32 has no effect.

DOUBLE and SINGLE values are rounded to the nearest UINT32 value on

conversion.

Some arithmetic operations are defined for UINT32 on interaction with

other UINT32 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

UINT32 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is UINT32.

UINT32 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the UINT32 class (as you

can for any object) by placing the appropriately named method in an

@uint32 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large UINT32 arrays is:

I = zeros(1000,1000,'uint32')

which creates a 1000x1000 element UINT32 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'uint32')

See also double, single, datatypes, isinteger, uint8, uint16, uint64, int8,

int16, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/uint32

categorical/uint32

Reference page in Help browser

doc uint32

<uint64> - Convert to unsigned 64-bit integer.

UINT64 Convert to unsigned 64-bit integer.

I = UINT64(X) converts the elements of the array X into unsigned

64-bit integers. X can be any numeric object, such as a DOUBLE.

DOUBLE and SINGLE values are rounded to the nearest UINT64 value

on conversion. If X is already an unsigned 64-bit integer array,

then UINT64 has no effect.

The values of a UINT64 range from 0 to 18,446,744,073,709,551,615,

(that is, from INTMIN('uint64') to INTMAX('uint64')). Values outside

this range are mapped to INTMIN('uint64') or INTMAX('uint64').

Some arithmetic operations are defined for UINT64 on interaction with

other UINT64 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

UINT64 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is UINT64.

UINT64 arrays saturate on overflow in arithmetic.

You can define your own methods for the UINT64 class (as you can for any

object) by placing the appropriately named method in an @uint64

directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large UINT64 arrays is:

I = zeros(100,100,'uint64')

which creates a 100x100 element UINT64 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'uint64')

See also double, single, datatypes, isinteger, uint8, uint16, uint32,

int8, int16, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/uint64

categorical/uint64

Reference page in Help browser

doc uint64

<int8> - Convert to signed 8-bit integer.

INT8 Convert to signed 8-bit integer.

I = INT8(X) converts the elements of the array X into signed 8-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of an INT8 range from -128 to 127, or INTMIN('int8') to INTMAX('int8').

Values outside this range saturate on overflow, namely they are mapped

to -128 or 127 if they are outside the range. If X is already a signed

8-bit integer array, then INT8 has no effect. DOUBLE and SINGLE values

are rounded to the nearest INT8 value on conversion.

Some arithmetic operations are defined for INT8 on interaction with

other INT8 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

INT8 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is INT8.

INT8 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the INT8 class (as you

can for any object) by placing the appropriately named method in an

@int8 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large INT8 arrays is:

I = zeros(1000,1000,'int8')

which creates a 1000x1000 element INT8 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'int8')

See also double, single, datatypes, isinteger, uint8, uint16, uint32,

uint64, int16, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/int8

categorical/int8

Reference page in Help browser

doc int8

<int16> - Convert to signed 16-bit integer.

INT16 Convert to signed 16-bit integer.

I = INT16(X) converts the elements of the array X into signed 16-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of an INT16 range from -32768 to 32767, or INTMIN('int16') to

INTMAX('int16'). Values outside this range saturate on overflow, namely

they are mapped to -32768 or 32767 if they are outside the range. If X

is already a signed 16-bit integer array, then INT16 has no effect.

DOUBLE and SINGLE values are rounded to the nearest INT16 value on

conversion.

Some arithmetic operations are defined for INT16 on interaction with

other INT16 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

INT16 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is INT16.

INT16 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the INT16 class (as you

can for any object) by placing the appropriately named method in an

@int16 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large INT16 arrays is:

I = zeros(1000,1000,'int16')

which creates a 1000x1000 element INT16 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'int16')

See also double, single, datatypes, isinteger, uint8, uint16, uint32,

uint64, int8, int32, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/int16

categorical/int16

Reference page in Help browser

doc int16

<int32> - Convert to signed 32-bit integer.

INT32 Convert to signed 32-bit integer.

I = INT32(X) converts the elements of the array X into signed 32-bit

integers. X can be any numeric object, such as a DOUBLE. The values

of an INT32 range from -2,147,483,648 to 2,147,483,647, or

INTMIN('int32') to INTMAX('int32'). Values outside this range saturate

on overflow, namely they are mapped to -2,147,483,648 or 2,147,483,647

if they are outside the range. If X is already a signed 32-bit integer

array, then INT32 has no effect. DOUBLE and SINGLE values are rounded

to the nearest INT32 value on conversion.

Some arithmetic operations are defined for INT32 on interaction with

other INT32 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

INT32 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is INT32.

INT32 arrays saturate on overflow in arithmetic.

You can define or overload your own methods for the INT32 class (as you

can for any object) by placing the appropriately named method in an

@int32 directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large INT32 arrays is:

I = zeros(1000,1000,'int32')

which creates a 1000x1000 element INT32 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'int32')

See also double, single, datatypes, isinteger, uint8, uint16, uint32,

uint64, int8, int16, int64, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/int32

categorical/int32

Reference page in Help browser

doc int32

<int64> - Convert to signed 64-bit integer.

INT64 Convert to signed 64-bit integer.

I = INT64(X) converts the elements of array X into signed 64-bit

integers. X can be any numeric object (such as a DOUBLE). DOUBLE

and SINGLE values are rounded to the nearest INT64 value on

conversion. If X is already a signed 64-bit integer array, then

INT64 has no effect.

The values of an INT64 range from -9,223,372,036,854,775,808 to

9,223,372,036,854,775,807, (that is, from INTMIN('int64') to

INTMAX('int64')). Values outside this range are mapped to INTMIN('int64')

or INTMAX('int64').

Some arithmetic operations are defined for INT64 on interaction with

other INT64 arrays. For example, +, -, .*, ./, .\ and .^.

If at least one operand is scalar, *, /, \ and ^ are also defined.

INT64 arrays may also interact with scalar DOUBLE variables, including

constants, and the result of the operation is INT64.

INT64 arrays saturate on overflow in arithmetic.

You can define your own methods for the INT64 CLASS (as you can for any

object) by placing the appropriately named method in an @int64

directory within a directory on your path.

Type HELP DATATYPES for the names of the methods you can overload.

A particularly efficient way to initialize a large INT64 arrays is:

I = zeros(100,100,'int64')

which creates a 100x100 element INT64 array, all of whose entries are

zero. You can also use ONES and EYE in a similar manner.

Example:

X = 17 * ones(5,6,'int64')

See also double, single, datatypes, isinteger, uint8, uint16, uint32,

uint64, int8, int16, int32, intmin, intmax, eye, ones, zeros.

Overloaded methods:

codistributed/int64

categorical/int64

Reference page in Help browser

doc int64

<inline> - Construct INLINE 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

<function_handle> - Function handle array.

FUNHANDLE = @FUNCTION_NAME returns a handle to the named function,

FUNCTION_NAME. A function handle is a MATLAB value that provides a

means of calling a function indirectly. You can pass function

handles in calls to other functions (which are often called function

functions). You can also store function handles in data structures for

later use (for example, as Handle Graphics callbacks). A function

handle is one of the standard MATLAB data types. Its class is

'function_handle'.

FUNHANDLE = @(ARGLIST)EXPRESSION constructs an anonymous function and returns a handle to that function. The body of the function, to the

right of the parentheses, is a single MATLAB expression. ARGLIST is a

comma-separated list of input arguments. Execute the function by

calling it by means of the returned function handle, FUNHANDLE. For

more information on anonymous functions, see "Types of Functions" in

the MATLAB Programming documentation.

To call the function referred to by a function handle value, use ordinary

parenthesis notation. That is, specify the function handle variable

followed by a comma-separated list of input arguments enclosed in

parentheses. For example, HANDLE(ARG1, ARG2, ...). To call a

function_handle with no arguments, use empty parenthesis, e.g.,

HANDLE().

Example 2, below, shows how to make a call using a function handle

that has been passed as an argument.

When you evaluate a function handle to a subfunction or private

function, that subfunction or private function is always executed when

the function handle is called. When you evaluate a function handle to

a built-in or ordinary function, an appropriate method may be selected

instead of the built-in or ordinary function.

With one exception, function handles can be manipulated and operated on in

the same manner as other MATLAB values, including assignment to variables

and inclusion in cells and structs. The exception is that you cannot

construct a function_handle array. The reason is that the parenthesis

notation for values of this class is used to call a function, not to

index an array. To achieve the effect of an array of function handles,

use cells, e.g., write "A = {@sin, @cos}" rather than "A = [@sin, @cos]".

Of course, you need to index A with braces: "A{i}".

Function handles enable you to:

Pass a function reference to another function.

Reduce the number of files that define your functions.

Improve performance in repeated operations.

Ensure reliability when evaluating functions.

Example 1 - Construct a handle, f, to the HUMPS function, and pass this

handle to FMINBND. (MATLAB maps a specific implementation of the HUMPS

function to the handle f at the time the handle is created, and not at

the time f is called.)

f = @humps;

x = fminbnd(f,1,2);

Example 2 - Call a function by means of the function handle, h, that

was passed as an argument.

function trigPlot(h, val)

if isa(h, 'function_handle') % Verify that h is a function handle.

A = h(val); % Call the function mapped to handle h.

plot(A) % Plot the resulting data.

end

Call the function, passing the handle generated by @cos:

trigPlot(@cos, -pi:0.01:pi)

See also func2str, str2func, functions.

Reference page in Help browser

doc function_handle

<javaArray> - Construct a Java Array object.

javaArray Construct a Java Array Object

JA = javaArray(CLASSNAME,DIM1,...) returns a Java array object

(an object with Java dimensionality), the component class of which

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