@@ -164,7 +164,7 @@ def parallel(sys1, *sysn, **kwargs):
164
164
or `y`). See :class:`InputOutputSystem` for more information.
165
165
states : str, or list of str, optional
166
166
List of names for system states. If not given, state names will be
167
- of of the form `x[i]` for interconnections of linear systems or
167
+ of the form `x[i]` for interconnections of linear systems or
168
168
'<subsys_name>.<state_name>' for interconnected nonlinear systems.
169
169
name : string, optional
170
170
System name (used for specifying signals). If unspecified, a generic
@@ -511,7 +511,7 @@ def connect(sys, Q, inputv, outputv):
511
511
512
512
return Ytrim * sys * Utrim
513
513
514
- def combine_tf (tf_array ):
514
+ def combine_tf (tf_array , ** kwargs ):
515
515
"""Combine array-like of transfer functions into MIMO transfer function.
516
516
517
517
Parameters
@@ -527,6 +527,16 @@ def combine_tf(tf_array):
527
527
TransferFunction
528
528
Transfer matrix represented as a single MIMO TransferFunction object.
529
529
530
+ Other Parameters
531
+ ----------------
532
+ inputs, outputs : str, or list of str, optional
533
+ List of strings that name the individual signals. If not given,
534
+ signal names will be of the form `s[i]` (where `s` is one of `u`,
535
+ or `y`). See :class:`InputOutputSystem` for more information.
536
+ name : string, optional
537
+ System name (used for specifying signals). If unspecified, a generic
538
+ name <sys[id]> is generated with a unique integer id.
539
+
530
540
Raises
531
541
------
532
542
ValueError
@@ -541,26 +551,34 @@ def combine_tf(tf_array):
541
551
--------
542
552
Combine two transfer functions
543
553
544
- >>> s = control.TransferFunction.s
545
- >>> control.combine_tf([
546
- ... [1 / (s + 1)],
547
- ... [s / (s + 2)],
548
- ... ])
549
- TransferFunction([[array([1])], [array([1, 0])]],
550
- [[array([1, 1])], [array([1, 2])]])
554
+ >>> s = ct.tf('s')
555
+ >>> ct.combine_tf(
556
+ ... [[1 / (s + 1)],
557
+ ... [s / (s + 2)]],
558
+ ... name='G'
559
+ ... )
560
+ TransferFunction(
561
+ [[array([1])],
562
+ [array([1, 0])]],
563
+ [[array([1, 1])],
564
+ [array([1, 2])]],
565
+ name='G', outputs=2, inputs=1)
551
566
552
567
Combine NumPy arrays with transfer functions
553
568
554
- >>> control.combine_tf([
555
- ... [np.eye(2), np.zeros((2, 1))],
556
- ... [np.zeros((1, 2)), control.TransferFunction([1], [1, 0])],
557
- ... ])
558
- TransferFunction([[array([1.]), array([0.]), array([0.])],
559
- [array([0.]), array([1.]), array([0.])],
560
- [array([0.]), array([0.]), array([1])]],
561
- [[array([1.]), array([1.]), array([1.])],
562
- [array([1.]), array([1.]), array([1.])],
563
- [array([1.]), array([1.]), array([1, 0])]])
569
+ >>> ct.combine_tf(
570
+ ... [[np.eye(2), np.zeros((2, 1))],
571
+ ... [np.zeros((1, 2)), ct.tf([1], [1, 0])]],
572
+ ... name='G'
573
+ ... )
574
+ TransferFunction(
575
+ [[array([1.]), array([0.]), array([0.])],
576
+ [array([0.]), array([1.]), array([0.])],
577
+ [array([0.]), array([0.]), array([1])]],
578
+ [[array([1.]), array([1.]), array([1.])],
579
+ [array([1.]), array([1.]), array([1.])],
580
+ [array([1.]), array([1.]), array([1, 0])]],
581
+ name='G', outputs=3, inputs=3)
564
582
"""
565
583
# Find common timebase or raise error
566
584
dt_list = []
@@ -616,10 +634,14 @@ def combine_tf(tf_array):
616
634
"Mismatched number transfer function inputs in row "
617
635
f"{ row_index } of denominator."
618
636
)
619
- return tf .TransferFunction (num , den , dt = dt )
637
+ return tf .TransferFunction (num , den , dt = dt , ** kwargs )
638
+
620
639
621
640
def split_tf (transfer_function ):
622
- """Split MIMO transfer function into NumPy array of SISO tranfer functions.
641
+ """Split MIMO transfer function into NumPy array of SISO transfer functions.
642
+
643
+ System and signal names for the array of SISO transfer functions are
644
+ copied from the MIMO system.
623
645
624
646
Parameters
625
647
----------
@@ -635,21 +657,29 @@ def split_tf(transfer_function):
635
657
--------
636
658
Split a MIMO transfer function
637
659
638
- >>> G = control.TransferFunction(
639
- ... [
640
- ... [[87.8], [-86.4]],
641
- ... [[108.2], [-109.6]],
642
- ... ],
643
- ... [
644
- ... [[1, 1], [1, 1]],
645
- ... [[1, 1], [1, 1]],
646
- ... ],
660
+ >>> G = ct.tf(
661
+ ... [ [[87.8], [-86.4]],
662
+ ... [[108.2], [-109.6]] ],
663
+ ... [ [[1, 1], [1, 1]],
664
+ ... [[1, 1], [1, 1]], ],
665
+ ... name='G'
647
666
... )
648
- >>> control.split_tf(G)
649
- array([[TransferFunction(array([87.8]), array([1, 1])),
650
- TransferFunction(array([-86.4]), array([1, 1]))],
651
- [TransferFunction(array([108.2]), array([1, 1])),
652
- TransferFunction(array([-109.6]), array([1, 1]))]], dtype=object)
667
+ >>> ct.split_tf(G)
668
+ array([[TransferFunction(
669
+ array([87.8]),
670
+ array([1, 1]),
671
+ name='G', outputs=1, inputs=1), TransferFunction(
672
+ array([-86.4]),
673
+ array([1, 1]),
674
+ name='G', outputs=1, inputs=1)],
675
+ [TransferFunction(
676
+ array([108.2]),
677
+ array([1, 1]),
678
+ name='G', outputs=1, inputs=1), TransferFunction(
679
+ array([-109.6]),
680
+ array([1, 1]),
681
+ name='G', outputs=1, inputs=1)]],
682
+ dtype=object)
653
683
"""
654
684
tf_split_lst = []
655
685
for i_out in range (transfer_function .noutputs ):
@@ -660,6 +690,9 @@ def split_tf(transfer_function):
660
690
transfer_function .num_array [i_out , i_in ],
661
691
transfer_function .den_array [i_out , i_in ],
662
692
dt = transfer_function .dt ,
693
+ inputs = transfer_function .input_labels [i_in ],
694
+ outputs = transfer_function .output_labels [i_out ],
695
+ name = transfer_function .name
663
696
)
664
697
)
665
698
tf_split_lst .append (row )
0 commit comments