Add `combine()` and `split()` functions for transfer matrices by sdahdah · Pull Request #1073 · python-control/python-control

Thanks for the contribution! This will make a nice addition.

Lots of little suggestions herein, mainly to keep things consistent with other code in the package.

One bigger picture question is on the function names: since these only work for transfer functions, I wonder if the function names shouldn't be combine_tf and split_tf (using 'tf' rather than transfer_function since the factor function is tf).

Also, I think there needs to be some checking for size consistency. For example, consider the following code:

import control as ct
sys1 = ct.tf(ct.rss(2, 1, 2))
sys2 = ct.tf(ct.rss(2, 2, 1))
sys = ct.combine([[sys1, sys2]])

The first system has 1 output and the second system has two outputs, so I think this should generate an error. Instead, I get a 3 input (correct) by 1 output (incorrect) system. If instead I do

sys = ct.combine([[sys2, sys1]])

I get an error message:

    587 for col in row:
    588     for j_in in range(col.ninputs):
--> 589         num_row.append(col.num[j_out][j_in])
    590         den_row.append(col.den[j_out][j_in])
    591 num.append(num_row)

IndexError: list index out of range

Shouldn't both forms generate error messages (perhaps saying that there are an inconsistent number of outputs in row 1)?