Hi Subashini,
To build a model that reads input from array elements one by one, following steps can be followed:
- Use a Constant block to define your array. Set the value to your array.
- Connect the Constant block to a Width block. This block will output the number of elements in the array.
- Add a constant block and set it to 1. This will act as the initial condition to the while iterator subsystem.
- 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.
- 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.
- Connect a Display block to the output of the Selector block. This block acts the LCD display.
- 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 '<='.
- 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:
The While Iterator Subsystem would look something like this:
Please refer to the following documentation to read more about these blocks:
- Width Block: https://www.mathworks.com/help/simulink/slref/width.html
- While Iterator Subsystem Block: https://www.mathworks.com/help/simulink/slref/whileiteratorsubsystem.html
- Selector Block: https://www.mathworks.com/help/simulink/slref/selector.html
- Counter Free-Running Block: https://www.mathworks.com/help/simulink/slref/counterfreerunning.html
- Relational Operator Block: https://www.mathworks.com/help/simulink/slref/relationaloperator.html
- Switch Block: https://www.mathworks.com/help/simulink/slref/switch.html
Hope this helps!