Convert simple LTI state-space feedback system from Simulink
See original GitHub issueFirst of all, great work on this toolbox. We in the gravitational wave instrumentation community are trying to ditch MATLAB and use tools like this in Python to model control systems and dynamics. I’ve got what I think is a pretty basic question but I hope someone has some time to help. I hope this is the right place to post this sort of question.
I’m trying to convert a Simulink model for a triple-stage pendulum that looks like this…

…into a python-control system. It’s a relatively simple model implemented as a state-space system (the red SSM100g block) with a few feedback loops and some input/output combining. I’ve got as far as implementing the ABCD matrices from the SSM100g model:
import numpy as np
from control import ss
A = [...] # 36x36 matrix
B = [...] # 36x24 matrix
C = [...] # 24x36 matrix
D = np.zeros((24, 24))
SUS_TRIPLE = ss(A, B, C, D)
This seems to work ok, I can plot transfer functions etc. with SUS_TRIPLE.freqresp(...) but now I’d like to combine some of the inputs and outputs into “higher level” inputs and outputs (act_1_x etc.) and add some feedback (turqoise gain and sum blocks) as per the screenshot above. I see there is a “Feedback interconnection” command but I don’t know whether it’s appropriate here. I also wonder if there is some way to abstract some of the low-level inputs/outputs of this state-space model into higher level ones, akin to Simulink’s “subsystem” blocks. In the end I’d like to have another system that I can again call .freqresp(...) on.
Is this possible to do? Are there perhaps some examples showing how to do this? I guess this is or will be a common task in the future, converting Simulink models to python-control. Any help would be appreciated!
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (9 by maintainers)

Top Related StackOverflow Question
Because
linearize()numerically simulates the dynamics of the connected model and catches the feedback.https://github.com/python-control/python-control/blob/6b24bb42a8da5b15cb79699e74fb33b30ba7935a/control/iosys.py#L549-L561
https://github.com/python-control/python-control/blob/6b24bb42a8da5b15cb79699e74fb33b30ba7935a/control/iosys.py#L1021-L1048
Depending on your system you still lose precision by converting to non-linear and performing these numerical calculations. Extending
InterconnectedSystemto directly connect linear systems would be a good enhancement IMHO.@murrayrm Thanks for the feature implementations! I haven’t forgotten about this, hopefully I can make a PR for you soon.