Products & Services Solutions Academia Support User Community Company

Learn more about Control System Toolbox   

Indexing into LTI Arrays

When to Index into LTI Arrays

You can index into LTI arrays in much the same way as you would for multidimensional arrays to

Organization of Indices

When you index into an LTI array sys, the indices should be organized according to the following format

where

Note on Indexing into LTI Arrays of FRD Models

For FRD models, the array indices can be followed by the keyword 'frequency' and some expression selecting a subset of the frequency points as in

sys (outputs, inputs, n1,...,nk, 'frequency', SelectedFreqs)

See Referencing FRD Models Through Frequencies for details on frequency point selection in FRD models.

Accessing Particular Models in an LTI Array

To access any given model in an LTI array:

For example, if sys is a 5-by-2 array of state-space models defined by

sys = rss(4,3,2,5,2);

you can access (and display) the model located in the (3,2) position of the array sys by typing

sys(:,:,3,2)

If sys is a 5-by-2 array of 3-output, 2-input FRD models, with frequency vector [1,2,3,4,5], then you can access the response data corresponding to the middle frequency (3 rad/s), of the model in the (3,1) position by typing

sys(:,:,3,1,'frequency',3.0)

To access all frequencies of this model in the array, you can simply type

sys(:,:,3,1)

Single Index Referencing of Array Dimensions

You can also access models using single index referencing of the array dimensions.

For example, in the 5-by-2 LTI array sys above, you can also access the model located in the (3,2) position by typing

sys(:,:,8)

since this model is in the eighth position if you were to list the 10 models in the array by successively scanning through its entries along each of its columns.

For more information on single index referencing, see Linear Indexing in the MATLAB online documentation.

Extracting LTI Arrays of Subsystems

To select a particular subset of I/O channels from all the models in an LTI array, use the syntax described in Extracting and Modifying Subsystems. For example,

sys = rss(4,3,2,5,2);
A = sys(1, [1 2])

or equivalently,

A = sys(1,[1 2],:,:)

selects the first two input channels, and the first output channel in each model of the LTI array A, and returns the resulting 5-by-2 array of one-output, two-input subsystems.

You can also combine model selection with I/O selection within an LTI array. For example, to access both:

type

sys(1,2,3,2)

To access the subsystem from all inputs to the first two output channels of this same array entry, type

sys(1:2,:,3,2)

Reassigning Parts of an LTI Array

You can reassign entire models or portions of models in an LTI array. For example,

sys = rss(4,3,2,5,2);	 % 5X2 array of state-space models
H = rss(4,1,1,5,2);	 % 5X2 array of SISO models
sys(1,2) = H

reassigns the subsystem from input two to output one, for all models in the LTI array sys. This SISO subsystem of each model in the LTI array is replaced with the LTI array H of SISO models. This one-line assignment command is equivalent to the following 10-step nested for loop.

for k = 1:5
  for j = 1:2
    sys(1,2,k,j) = H(:,:,k,j);
  end
end

Notice that you don't have to use the array dimensions with this assignment. This is because I/O selection applies to all models in the array when the array indices are omitted.

Similarly, the commands

sys(:,:,3,2) = sys(:,:,4,1);
sys(1,2,3,2) = 0;

reassign the entire model in the (3,2) position of the LTI array sys and the (1,2) subsystem of this model, respectively.

Deleting Parts of an LTI Array

You can use indexing to delete any part of an LTI array by reassigning it to be empty ([]). For instance,

sys = rss(4,3,2,5,2);
sys(1,:) = [];
size(sys)

5x2 array of continuous-time state-space models
Each model has 2 outputs, 2 inputs, and 4 states.

deletes the first output channel from every model of this LTI array.

Similarly,

sys(:,:,[3 4],:) = []

deletes the third and fourth rows of this two-dimensional array of models.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS