Working with arrays in simulink

11 visualizaciones (últimos 30 días)
Subashini De Silva
Subashini De Silva el 23 de Dic. de 2019
Respondida: Jaynik el 6 de Nov. de 2024 a las 7:01
Hi,
I am trying to build a simulink model to read and send an array elements one by one to display on my lcd.
For that I am reading the size of the array using 'width' block. With the help of a while loop blcok I am trying to use an iterative process to read the elements of the array. I couldn't find enough uidance for this task and I am a beginner to matlab simulink.
Please help me with this.

Respuestas (1)

Jaynik
Jaynik el 6 de Nov. de 2024 a las 7:01
Hi Subashini,
To build a model that reads input from array elements one by one, following steps can be followed:
  1. Use a Constant block to define your array. Set the value to your array.
  2. Connect the Constant block to a Width block. This block will output the number of elements in the array.
  3. Add a constant block and set it to 1. This will act as the initial condition to the while iterator subsystem.
  4. Add a While Iterator Subsystem block. Connect the Constant block added in step 3 to the IC port and the Width block to the other port of the subsystem.
  5. Add a Selector block. Set the index option to Index Vector (port). Connect the output of the iterator subsystem to the index port of the Selector block. Connect the Constant block added in step 1 to the input of the Selector block.
  6. Connect a Display block to the output of the Selector block. This block acts the LCD display.
  7. Open the While Iterator Subsystem. Add a Counter Free Running Block, a Relational Operator Block, a Switch block. Connect the counter to the Relational Operator block and the first input of the Switch block. Set the Relational Operator to '<='.
  8. Connect the Relational Operator Block to the control of the Switch Block. Connect a Constant block to handle the out of bound index to the second input of the Switch block.
After following the above steps, the final model should look something like this:
Base Model
The While Iterator Subsystem would look something like this:
While Iterator Subsystem
Please refer to the following documentation to read more about these blocks:
Hope this helps!

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by