I have a Simulink error I can't figure out, relating to the Time-Varying State Space block dimensions.
I'm using this block so that i can also get x : normal SS block doesn't output x.
This is a simple 2x2 system, and the system dimensions are correct, but I'm getting a port dims error -- it seems to be Output Port 2 (the length-2 "x" output). It could be any system, i happen to have a closed-loop state space, but anything triggers the same error.
Any thoughts why?
I've spent way too much time trying to figure out what's going on...
SL model attached, and Runnable code below.
Error:
Matrix multiply dimensions propagation error. Error occurred while setting output port of 'LQR_post/Varying State Space/Product1' to have the dimensions [1 x 2]. A possible cause for this error is that these dimensions do not agree with the partial dimensions information present on other ports Component:Simulink | Category:Model error
Component:Simulink | Category:Model error
Code:
A = [0, 1; -k / J, -b / J];
'StateName', {'x', 'x dot'}, ...
'InputName', {'r(ref)'}, ...
'OutputName', {'theta'});
[K_lqr, S1, P1] = lqr(sys, Q, R);
sys_lqr = ss(sys.A - sys.B * K_lqr, sys.B * K_lqr * [1;0], sys.C, sys.D);
sys_lqr.StateName = {'theta', 'angVel'};
sys_lqr.InputName = {'r(ref)'};
sys_lqr.OutputName = {'theta'};
sys_lqr
sys_lqr =
A =
theta angVel
theta 0 1
angVel -3.162e+07 -3.261e+04
B =
r(ref)
theta 0
angVel 3.156e+07
C =
theta angVel
theta 1 0
D =
r(ref)
theta 0
Continuous-time state-space model.