Signal dimension in Simulink change when fed back in closed loop

4 Ansichten (letzte 30 Tage)
I have a Simulink model. I used MATLAB user defined functions to build my model. The signal propagating in the system are either 3x3 matrix or a 3x1 column vector. I am building a controller. Everything works perfectly fine when I am using an open loop connection. However, as soon as I close the loop the dimensions get missed up, and every 3x1 vector - which is supposed to be fed back- turns into a scalar value. So, whenever I try to extract it's content within any of my user-defined functions I get this error: "Index expression out of bounds. Attempted to access element 2. The valid range is 1-1." So I am getting a scalar instead of a vector. In the attached image: each of q, qdot and qdotdot is a 3x1 column vector. How can I solve this??
<<
>>

Akzeptierte Antwort

Vineeth Kartha
Vineeth Kartha am 17 Mär. 2016
Hi,
Sometimes Simulink is unable to determine the size of signals without additional specification. This is especially the case with MATLAB function blocks since the code written inside this block under goes code generation. The conversion of C-code requires signal dimensionality to be known in advance prior to code generation.
The solution to this is to make use of signal specification blocks to define the size of signals prior to inputting them back into MATLAB function blocks.
Hope this helps
Regards
Vineeth

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by