Signal dimension in Simulink change when fed back in closed loop

4 visualizaciones (últimos 30 días)
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??
<<
>>

Respuesta aceptada

Vineeth Kartha
Vineeth Kartha el 17 de Mzo. de 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

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by