Signal dimension in Simulink change when fed back in closed loop

7 次查看(过去 30 天)
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??
<<
>>

采纳的回答

Vineeth Kartha
Vineeth Kartha 2016-3-17
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by