size

Returns the size of each dimension of an object.

Syntax

v = size(x)

d = size(x, dim)

[d1,d2,...] = size(x)

Inputs

x
A matrix or other object with dimensions.
Type: double | integer | logical | string | struct | cell
Dimension: matrix
dim
The dimension of interest.
Type: double
Dimension: scalar

Outputs

v
A vector containing the dimensions.
d
A scalar dimension.
d1, d2, ...
The dimensions of x.

Examples

Vector output:

R = size([1,3,2;5,2,3;9,2,3;1,1,1])
R = [ 4 3 ]

Single dimension output:

R = size([1,3,2;5,2,3;9,2,3;1,1,1],2)
R = 3

Multiple dimension output:

[r,c] = size([1,3,2;5,2,3;9,2,3;1,1,1])
r = 4
c = 3