Fix bug in matched transformation + address other issues in #950 - #951
Merged
Conversation
Co-authored-by: Sawyer Fuller <58706249+sawyerbfuller@users.noreply.github.com>
gaoflow
added a commit
to gaoflow/python-control
that referenced
this pull request
Aug 9, 2026
TransferFunction.sample(Ts, method='matched') (and c2d) returned an all-NaN numerator for any system with a pole or zero at s = 0 - integrators, PI/PID controllers, differentiators and other type-1/2 systems. The DC-gain match divides the continuous DC gain (inf for an origin pole, 0 for an origin zero) by a zgain that carries the same vanishing 1 - z factor, so the gain is 0/0 or inf/inf. Match the gain from the non-origin factors only and restore the origin scaling analytically through the z - 1 ~ s*Ts limit, which recovers the textbook Ts/(z - 1) for 1/s, Ts**2/(z - 1)**2 for 1/s**2, and so on. Finite-DC systems are byte-for-byte unchanged. Completes the gain fix from python-control#950/python-control#951.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the calculation of the DC gain in the 'matched' transformation from continuous time to discrete time. It also fixes some other issues identified in #950. Also adds unit test for
sample_systemthat catches the original error.