Skip to content

Commit 2185695

Browse files
jamestjspclaude
andcommitted
Fix tb04ad coefficient extraction using index array
tb04ad returns polynomial coefficients padded to max degree. The index array specifies actual degree per row. Without trimming, trailing zeros caused division by zero in DC gain calculations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1c63ccd commit 2185695

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

control/xferfcn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,11 +1542,13 @@ def _convert_to_transfer_function(
15421542
array(sys.B), array(sys.C), array(sys.D), tol1=0.0)
15431543

15441544
for i in range(sys.noutputs):
1545+
# index contains the degree of each row's denominator
1546+
deg_i = tfout[4][i]
15451547
for j in range(sys.ninputs):
1546-
num[i][j] = list(tfout[6][i, j, :])
1548+
num[i][j] = list(tfout[6][i, j, :deg_i+1])
15471549
# Each transfer function matrix row
15481550
# has a common denominator.
1549-
den[i][j] = list(tfout[5][i, :])
1551+
den[i][j] = list(tfout[5][i, :deg_i+1])
15501552

15511553
except ImportError:
15521554
# If slicot not available, do conversion using sp.signal.ss2tf

0 commit comments

Comments
 (0)