Documentation Center

  • Trial Software
  • Product Updates

stack

Build model array by stacking models or model arrays along array dimensions

Syntax

sys = stack(arraydim,sys1,sys2,...)

Description

sys = stack(arraydim,sys1,sys2,...) produces an array of dynamic system models sys by stacking (concatenating) the models (or arrays) sys1,sys2,... along the array dimension arraydim. All models must have the same number of inputs and outputs (the same I/O dimensions), but the number of states can vary. The I/O dimensions are not counted in the array dimensions. For more information about model arrays and array dimensions, see Model Arrays.

For arrays of state-space models with variable order, you cannot use the dot operator (e.g., sys.a) to access arrays. Use the syntax

[a,b,c,d] = ssdata(sys,'cell')

to extract the state-space matrices of each model as separate cells in the cell arrays a, b, c, and d.

Examples

Example 1

If sys1 and sys2 are two models:

  • stack(1,sys1,sys2) produces a 2-by-1 model array.

  • stack(2,sys1,sys2) produces a 1-by-2 model array.

  • stack(3,sys1,sys2) produces a 1-by-1-by-2 model array.

Example 2

Stack identified state-space models derived from the same estimation data and compare their bode responses.

load iddata1 z1
sysc = cell(1,5);
opt = ssestOptions('Focus','simulation');
for i = 1:5
sysc{i} = ssest(z1,i-1,opt);
end
sysArray = stack(1, sysc{:});
bode(sysArray);
Was this topic helpful?