Simulink state space system with close loop

4 views (last 30 days)
SV
SV on 16 Oct 2019
Answered: Pranjal Kaura on 31 Aug 2021
Hi everyone,
I need help to solve a problem.
I'm building a simulink system. I have an 'interpreted function' block where at the input there are values that I take from the work space of the main matlab, and in output it gives me a 1-D signal which is then input into the state space block. The state space block sends me two values, since my initial state is a 2x10 vector. Seeing with scope the graph gives me two signals that are row 1 and row 2 of my updated vector. How do I take one of the two lines of the state space block output, then insert it together with the initial inputs in the 'function interpreted' block and do a close loop?

Answers (1)

Pranjal Kaura
Pranjal Kaura on 31 Aug 2021
Hey,
It is my understanding that you want to extract a subset (a single row in your case) from the output of the state space block. You further want to pass this extracted vector into the 'function interpreted' block.
Variable Selector block can be used to extract a subset from the output of the state space block (say X). Since the shape of output 'X' is known, you can set the following parameters in the Variable selector block:
  • Number of input signals = 1
  • Selector Mode = 'Fixed'
  • Elements = [1] (2 if you want to extract the second row from the output X)
This extracted signal can then be concatenated to your inital inputs of the 'function interpreted' block using the Vector/Matrix concatenate block. You can further slice this input as per your requirement in the MATLAB function created for the 'function interpreted' block.

Categories

Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!