Array Operations

cell

Syntax

cell
cell(dimensions…)

Description

Returns a cell array containing empty matrices. A cell array can contain data of mixed types and sizes.

  • If dimensions are provided, they must contain non-negative integers supplying the dimensions of the cell array to be returned.
  • If called with a scalar, cell(n), this operator will return a square n x n cell array filled with empty matrices.
  • When called with no arguments, this function returns the result of cell(1).
  • The dimensions to a cell array must be concrete.

horzcat

Syntax

horzcat(a1,a2,…,an)

Description

Concatenate arrays a1,a2,…,an, horizontally, provided that all input arrays have the same number of rows. Symbolic inputs are permitted. If the input arrays contain unlike types, they will be combined as specified in the order of precedence below. If one of the input arrays is a

  1. function handle, then the result will be a function handle.
  2. struct array, then the result will be a struct array.
  3. cell array, then the result will also be a cell array.
  4. char array, then the result will also be a char array.
  5. numeric array and the left-most occurance has type
    • double, then the result will also have type double.
    • intN, then the result will also have type intN.
    • uintN, then the result will also have type uintN.
  6. logical array, then the result is also a logical array.

vertcat

Syntax

vertcat(a1,a2,…,an)

Description

Concatenate arrays a1,a2,…,an, vertically, provided that all input arrays have the same number of columns. Symbolic inputs are permitted. If the input arrays contain unlike types, they will be combined as specified in the order of precedence below. If one of the input arrays is a

  1. function handle, then the result will be a function handle.
  2. struct array, then the result will be a struct array.
  3. cell array, then the result will also be a cell array.
  4. char array, then the result will also be a char array.
  5. numeric array and the left-most occurance has type
    • double, then the result will also have type double.
    • intN, then the result will also have type intN.
    • uintN, then the result will also have type uintN.
  6. logical array, then the result is also a logical array.

length

Syntax

length(x)

Description

Returns the length of the largest dimension of input x. In other words, length(x) = max(size(x)). Symbolic inputs are permitted.

setdiff

Syntax

setdiff(x,y)

Description

Returns the array elements in x that do not appear in array y. The input arrays to setdiff are expected to share the same type and may either be char or double arrays. .. Does not accept symbolic inputs.

size

Syntax

d = size(x)
[d1,…,dn] = size(x)

size(x,dim)

Description

Gives the dimensions of the input array x.

  • When called with a single argument size(x) returns a vector, d, where each element is the size of a particular dimension in x. The length of d is equal to the number of dimensions in x.
  • If an output vector, [d1,…,dn], is given, then size(x) stores the size of each dimension of x in the variables d1,…,dn. The element di contains the size of the dimension i in x.
    • Suppose the number of dimensions, m, in x is greater than the number of provided output variables n. Then di equals the size of the ith dimension of x for 0 < i < n. The last element, dn, is the product of the sizes of the remaining dimensions of x, i.e. dimensions n through m.
    • Suppose the number of dimensions, m, in x is less than the number of provided output variables n. Then di = 1 one for those extra dimensions where m < i <= n.
  • When called with two arguments, size(x,dim), returns the size of the dimension of x given by the concrete positive integer dim.

squeeze

Syntax

squeeze(x)

Description

Returns a new array with all same elements as x but with all of the singleton dimensions removed. For example, if x had size [1 2 1 5 1] then size(squeeze(x)) = [2 5]. This operation accepts arrays with symbolic inputs.

ctranspose

Syntax

x'
ctranspose(x)

Description

The complex conjugate transpose operation will return a matrix with the elements in the rows and columns of x interchanged. The sign of the imaginary part of any complex numbers will become negated.

  • The input x may either be a vector or a 2D array. Additionally, it accepts arrays with symbolic elements.

transpose

Syntax

x.'
transpose(x)

Description

The nonconjugate transpose operation will return a matrix with the elements in the rows and columns of x interchanged. The sign of the imaginary part of any complex numbers will be left unchanged.

  • The input x may either be a vector or a 2D array. Additionally, it accepts arrays with symbolic elements.

permute

ipermute