@@ -413,7 +413,7 @@ def __str__(self):
413413 # represent to implement a re-loadable version
414414 def __repr__ (self ):
415415 """Print state-space system in loadable form."""
416- # TODO: add input/output names
416+ # TODO: add input/output names (?)
417417 return "StateSpace({A}, {B}, {C}, {D}{dt})" .format (
418418 A = self .A .__repr__ (), B = self .B .__repr__ (),
419419 C = self .C .__repr__ (), D = self .D .__repr__ (),
@@ -962,6 +962,7 @@ def zeros(self):
962962 # Feedback around a state space system
963963 def feedback (self , other = 1 , sign = - 1 ):
964964 """Feedback interconnection between two LTI systems."""
965+ # Convert the system to state space, if possible
965966 try :
966967 other = _convert_to_statespace (other )
967968 except :
@@ -2293,114 +2294,3 @@ def _rss_generate(
22932294 else :
22942295 ss_args = (A , B , C , D , True )
22952296 return StateSpace (* ss_args , name = name )
2296-
2297-
2298- def _mimo2siso (sys , input , output , warn_conversion = False ):
2299- # pylint: disable=W0622
2300- """
2301- Convert a MIMO system to a SISO system. (Convert a system with multiple
2302- inputs and/or outputs, to a system with a single input and output.)
2303-
2304- The input and output that are used in the SISO system can be selected
2305- with the parameters ``input`` and ``output``. All other inputs are set
2306- to 0, all other outputs are ignored.
2307-
2308- If ``sys`` is already a SISO system, it will be returned unaltered.
2309-
2310- Parameters
2311- ----------
2312- sys : StateSpace
2313- Linear (MIMO) system that should be converted.
2314- input : int
2315- Index of the input that will become the SISO system's only input.
2316- output : int
2317- Index of the output that will become the SISO system's only output.
2318- warn_conversion : bool, optional
2319- If `True`, print a message when sys is a MIMO system,
2320- warning that a conversion will take place. Default is False.
2321-
2322- Returns
2323- sys : StateSpace
2324- The converted (SISO) system.
2325- """
2326- if not (isinstance (input , int ) and isinstance (output , int )):
2327- raise TypeError ("Parameters ``input`` and ``output`` must both "
2328- "be integer numbers." )
2329- if not (0 <= input < sys .ninputs ):
2330- raise ValueError ("Selected input does not exist. "
2331- "Selected input: {sel}, "
2332- "number of system inputs: {ext}."
2333- .format (sel = input , ext = sys .ninputs ))
2334- if not (0 <= output < sys .noutputs ):
2335- raise ValueError ("Selected output does not exist. "
2336- "Selected output: {sel}, "
2337- "number of system outputs: {ext}."
2338- .format (sel = output , ext = sys .noutputs ))
2339- # Convert sys to SISO if necessary
2340- if sys .ninputs > 1 or sys .noutputs > 1 :
2341- if warn_conversion :
2342- warn ("Converting MIMO system to SISO system. "
2343- "Only input {i} and output {o} are used."
2344- .format (i = input , o = output ))
2345- # $X = A*X + B*U
2346- # Y = C*X + D*U
2347- new_B = sys .B [:, input ]
2348- new_C = sys .C [output , :]
2349- new_D = sys .D [output , input ]
2350- sys = StateSpace (
2351- sys .A , new_B , new_C , new_D , sys .dt ,
2352- name = sys .name ,
2353- inputs = sys .input_labels [input ], outputs = sys .output_labels [output ])
2354-
2355- return sys
2356-
2357-
2358- def _mimo2simo (sys , input , warn_conversion = False ):
2359- # pylint: disable=W0622
2360- """
2361- Convert a MIMO system to a SIMO system. (Convert a system with multiple
2362- inputs and/or outputs, to a system with a single input but possibly
2363- multiple outputs.)
2364-
2365- The input that is used in the SIMO system can be selected with the
2366- parameter ``input``. All other inputs are set to 0, all other
2367- outputs are ignored.
2368-
2369- If ``sys`` is already a SIMO system, it will be returned unaltered.
2370-
2371- Parameters
2372- ----------
2373- sys: StateSpace
2374- Linear (MIMO) system that should be converted.
2375- input: int
2376- Index of the input that will become the SIMO system's only input.
2377- warn_conversion: bool
2378- If True: print a warning message when sys is a MIMO system.
2379- Warn that a conversion will take place.
2380-
2381- Returns
2382- -------
2383- sys: StateSpace
2384- The converted (SIMO) system.
2385- """
2386- if not (isinstance (input , int )):
2387- raise TypeError ("Parameter ``input`` be an integer number." )
2388- if not (0 <= input < sys .ninputs ):
2389- raise ValueError ("Selected input does not exist. "
2390- "Selected input: {sel}, "
2391- "number of system inputs: {ext}."
2392- .format (sel = input , ext = sys .ninputs ))
2393- # Convert sys to SISO if necessary
2394- if sys .ninputs > 1 :
2395- if warn_conversion :
2396- warn ("Converting MIMO system to SIMO system. "
2397- "Only input {i} is used." .format (i = input ))
2398- # $X = A*X + B*U
2399- # Y = C*X + D*U
2400- new_B = sys .B [:, input :input + 1 ]
2401- new_D = sys .D [:, input :input + 1 ]
2402- sys = StateSpace (
2403- sys .A , new_B , sys .C , new_D , sys .dt , name = sys .name ,
2404- inputs = sys .input_labels [input ], outputs = sys .output_labels )
2405-
2406- return sys
0 commit comments