Creating and Manipulating Models | ![]() ![]() |
size and ndims
You can access the dimensions and shape of an LTI array using:
size
to determine the lengths of each of the dimensions associated with an LTI arrayndims
to determine the total number of dimensions in an LTI arrayWhen applied to an LTI array, size
returns
[Ny Nu S1 S2 ... Sk]
Ny
is the number of outputs common to all models in the LTI array.Nu
is the number of inputs common to all models in the LTI array.Si
is the number of models along the ith array dimension.Note the following when using the size
function:
For single LTI models, size returns only the I/O dimensions [Ny Nu]
.
[Ny Nu 2 1]
size
ignores trailing singleton dimensions beyond the second array dimension. For example, size returns [Ny Nu 2 3]
for a 2-by-3-by-1-by-1 LTI array of models with Ny
outputs and Nu
inputs.The function ndims
returns the total number of dimensions in an LTI array:
p
, for LTI arrays, where p
(greater than 2) is the number of array dimensions ndims (sys) = length(size(sys))
To see how these work on the sample 2-by-3 LTI array m2d
of two-output, one-input models, type
load LTIexamples s = size(m2d) s = 2 1 2 3
Notice that size
returns a vector whose entries correspond to the length of each of the four dimensions of m2d
: two outputs and one input in a 2-by-3 array of models. Type
ndims(m2d) ans = 4
to see that there are indeed four dimensions attributed to this LTI array.
![]() | Dimensions, Size, and Shape of an LTI Array | reshape | ![]() |