Working with arrays in simulink

7 次查看(过去 30 天)
Subashini De Silva
Subashini De Silva 2019-12-23
回答: Jaynik 2024-11-6,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.

回答(1 个)

Jaynik
Jaynik 2024-11-6,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!

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by