create a variable array in simulink in matlab

To create a variable array in Simulink, you can use the Variable Size Signal or Variable-Size Arrays block.

Here's how to use the Variable-Size Arrays block:

  1. Open your Simulink model.
  2. From the Simulink Library Browser, select Simulink > Signal Routing.
  3. Drag and drop the Variable-Size Arrays block onto your model.
  4. Double-click the block to open its dialog box.
  5. In the dialog box, specify the maximum size of the array using the Maximum size parameter. This parameter is an array of integers that represents the maximum length of each dimension of the array. For example, to create a variable-length 1-D array that can hold up to 100 elements, set the Maximum size parameter to [100 1].
  6. Optionally, set the Minimum size parameter to specify the minimum size of the array. This parameter is also an array of integers.
  7. Connect the output port of the Variable-Size Arrays block to the input port of the next block in your model.

Here's an example usage of the Variable-Size Arrays block in Simulink:

Variable-Size Arrays block example

In this example, the Variable-Size Arrays block creates a 1-D array with a maximum size of 100 elements. The Constant block provides a 1-D array with a size of 3 elements. The Concatenate block concatenates the two arrays to create a 1-D array with a size between 3 and 100 elements, depending on the input values.

gistlibby LogSnag