- Notifications
You must be signed in to change notification settings - Fork445
Description
About the problem
Summary
I attempted to simulate a control system with an output-feedback controller, defining a plant and a controller as subsystems.
When usingcontrol.interconnect to connect these subsystems, an error occurs because an extended system obtained by connecting subsystems has zero input and one output.
Is it impossible to define a system with zero input and one output using thecontrol.interconnect function?
Error message
control.exception.ControlDimension: Incompatible dimensions of D matrix; expected (1, 0) but found (0, 0)System information
- OS: macOS Sonoma 14.3.1
- Python: 3.12.2
- python-control: 0.10.2
Cause of this problem
When we set the inputs and outputs of the extended system as zero input and one input, the D matrix of the extended system has(1, 0) dimension.
However, the dimension of D matrix is converted to(0, 0) dimension by_ssmatrix function at line 218 ofstatesp.py.
As a result, the mismatch of the dimensions occurs.
(When we set both inputs and outputs to zero, the error does not occur.)
To reproduce the error
importnumpyasnpimportcontrolasctdefmain():# Define the coefficient matrices of plant PA=np.array( [ [1.00,1.00], [0.00,-2.0], ] )B=np.array( [ [0.00], [1.00] ] )C=np.array( [ [1.00,0.00] ] )# Define the coefficient matrices of controller CA_c=np.array( [ [2.25,1.00], [-5.0,-0.5] ] )B_c=np.array( [ [-1.25], [4.500] ] )C_c=np.array( [ [-0.50,1.500] ] )# Define the subsystemsP=ct.ss(A,B,C,np.zeros([C.shape[0],B.shape[1]]),inputs=[f'u_p{i}'foriinrange(B.shape[1])],outputs=[f'y_p{i}'foriinrange(C.shape[0])],name='P',dt=True )C=ct.ss(A_c,B_c,C_c,np.zeros([C_c.shape[0],B_c.shape[1]]),inputs=[f'y_p{i}'foriinrange(B_c.shape[1])],outputs=[f'u_p{i}'foriinrange(C_c.shape[0])],name='C',dt=True )sys=ct.interconnect( [P,C],inplist=None,outlist=[f'y_p{i}'foriinrange(P.C.shape[0])] )if__name__=='__main__':main()