8000 allow naming of linearized system signals · python-control/python-control@fa041b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa041b6

Browse files
committed
allow naming of linearized system signals
1 parent 383e7a4 commit fa041b6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

control/iosys.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ def feedback(self, other=1, sign=-1, params={}):
494494
# Return the newly created system
495495
return newsys
496496

497-
def linearize(self, x0, u0, t=0, params={}, eps=1e-6):
497+
def linearize(self, x0, u0, t=0, params={}, eps=1e-6,
498+
name=None, copy=False, **kwargs):
498499
"""Linearize an input/output system at a given state and input.
499500
500501
Return the linearization of an input/output system at a given state
@@ -547,8 +548,20 @@ def linearize(self, x0, u0, t=0, params={}, eps=1e-6):
547548
D[:, i] = (self._out(t, x0, u0 + du) - H0) / eps
548549

549550
# Create the state space system
550-
linsys = StateSpace(A, B, C, D, self.dt, remove_useless=False)
551-
return LinearIOSystem(linsys)
551+
linsys = LinearIOSystem(
552+
StateSpace(A, B, C, D, self.dt, remove_useless=False),
553+
name=name, **kwargs)
554+
555+
# Set the names the system, inputs, outputs, and states
556+
if copy:
557+
linsys.ninputs, linsys.input_index = self.ninputs, \
558+
self.input_index.copy()
559+
linsys.noutputs, linsys.output_index = \
560+
self.noutputs, self.output_index.copy()
561+
linsys.nstates, linsys.state_index = \
562+
self.nstates, self.state_index.copy()
563+
564+
return linsys
552565

553566
def copy(self, newname=None):
554567
"""Make a copy of an input/output system."""
@@ -1759,6 +1772,11 @@ def linearize(sys, xeq, ueq=[], t=0, params={}, **kw):
17591772
params : dict, optional
17601773
Parameter values for the systems. Passed to the evaluation functions
17611774
for the system as default values, overriding internal defaults.
1775+
copy : bool, Optional
1776+
If `copy` is True, copy the names of the input signals, output signals,
1777+
and states to the linearized system.
1778+
name : string, optional
1779+
Set the name of the linearized system.
17621780
17631781
Returns
17641782
-------

0 commit comments

Comments
 (0)
0