[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Built-in Data Types

The standard built-in data types are real and complex scalars and matrices, ranges, character strings, a data structure type, and cell arrays. Additional built-in data types may be added in future versions. If you need a specialized data type that is not currently provided as a built-in type, you are encouraged to write your own user-defined data type and contribute it for distribution in a future release of Octave.

The data type of a variable can be determined and changed through the use of the following functions.

Built-in Function: class (expr)

Return the class of the expression expr, as a string.

Function File: isa (x, class)

Return true if x is a value from the class class.

Function File: cast (val, type)

Convert val to data type type.
See also: int8, uint8, int16, uint16, int32, uint32, int64, uint64, double.

Loadable Function: typecast (x, type)

Converts from one datatype to another without changing the underlying data. The argument type defines the type of the return argument and must be one of 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'single' or 'double'.

An example of the use of typecast on a little-endian machine is

 
x = uint16 ([1, 65535]);
typecast (x, 'uint8')
⇒ [   0,   1, 255, 255]

See also: cast, swapbytes.

Function File: swapbytes (x)

Swaps the byte order on values, converting from little endian to big endian and visa-versa. For example

 
swapbytes (uint16 (1:4))
⇒ [   256   512   768  1024]

See also: typecast, cast.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1 Numeric Objects

Octave's built-in numeric objects include real, complex, and integer scalars and matrices. All built-in floating point numeric data is currently stored as double precision numbers. On systems that use the IEEE floating point format, values in the range of approximately 2.2251e-308 to 1.7977e+308 can be stored, and the relative precision is approximately 2.2204e-16. The exact values are given by the variables realmin, realmax, and eps, respectively.

Matrix objects can be of any size, and can be dynamically reshaped and resized. It is easy to extract individual rows, columns, or submatrices using a variety of powerful indexing features. See section Index Expressions.

See section Numeric Data Types, for more information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.2 Missing Data

It is possible to represent missing data explicitly in Octave using NA (short for "Not Available"). Missing data can only be represented when data is represented as floating point numbers. In this case missing data is represented as a special case of the representation of NaN.

Built-in Function: NA (x)
Built-in Function: NA (n, m)
Built-in Function: NA (n, m, k, …)
Built-in Function: NA (…, class)

Return a matrix or N-dimensional array whose elements are all equal to the special constant used to designate missing values.

Mapping Function: isna (x)

Return 1 for elements of x that are NA (missing) values and zero otherwise. For example,

 
isna ([13, Inf, NA, NaN])
     ⇒ [ 0, 0, 1, 0 ]

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.3 String Objects

A character string in Octave consists of a sequence of characters enclosed in either double-quote or single-quote marks. Internally, Octave currently stores strings as matrices of characters. All the indexing operations that work for matrix objects also work for strings.

See section Strings, for more information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.4 Data Structure Objects

Octave's data structure type can help you to organize related objects of different types. The current implementation uses an associative array with indices limited to strings, but the syntax is more like C-style structures.

See section Data Structures, for more information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.5 Cell Array Objects

A Cell Array in Octave is general array that can hold any number of different data types.

See section Cell Arrays, for more information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on December, 26 2007 using texi2html 1.76.