Closed ToGoOrNotToGo closed 4 years ago
TF numerator is simply the impulse response (for FIR filters):
double[] impulseResponse;
//...
// IR -> TF
var tf = new TransferFunction(impulseResponse);
// TF -> IR
var kernel = tf.Numerator; // filter 'kernel' is a synonym for IR
The impulse response of IIR filters is infinite (hence, the name).
If you are asking about the Partial Fraction Expansion method (used for doing the inverse Z-transform and finding analytic representation of impulse response), it's not implemented. Although there's a method DesignFilter.TfToSos
decomposing TF into a collection of second-order sections TFs.
Yes I am looking for TF estimation of a given impulse response from an IIR filter by using Z-tranform. (and I start learning Z-Transform... oh and have to learn SOS... holy cow... ;-) )
Maybe a method like this is interesting for the TransferFunction class: https://www.mathworks.com/help/ident/ref/tfest.html
Impulse response of an IIR filter is infinite, so it can't be given in a finite array. Infinite impulse response can be derived only analytically from the TF / difference equations (so it's an inverse task).
For example, if we have TF 1 / (1-2z^-1)
then the impulse response for all |z| > 2
is: 2^n u[n], n = -∞, ..., -2, -1, 0, 1, 2, ... ∞
where u[n]
is the unit step function (i.e. infinite signal). DSP textbooks explain the math behind this.
Thus, you can have infinite impulse response only in analytic form like above and take Z-transform from it. I'm quite sure this is not what you need (most likely, you'll have just filter coefficients: non-recursive part of the difference equation is TF.Numerator and recursive part is TF.Denominator). But if I'm wrong then the symbolic math libraries can be used for analytical computations (like in this case - Z-transform series). This lib is not designed for these tasks.
Regarding tfest
- maybe it'll be added to NWaves someday )). However, it solves another task: it finds the best estimate of the TF based on input/output in time domain or system behaviour in frequency domain.
There are more techniques calculation TF: "Impulse invariance" and "TF from bode plot"... But Z-transform seems to be the most interesting topic...
OK, this issue starts becoming like 'contemplations about everything' )). I gave the answer regarding the topic of the issue in my first answer. All in all, you raised three completely different tasks:
tfest
)The first task is for symbolic math libraries like symPy. This lib is more practically oriented.
The second task is OK, although it's not related to the topic of the issue. I marked it as an 'enhancement'.
Regarding the third task, in this lib the so called BilinearTransform
is implemented - it does the same thing and it's used in IIR filter design. I was also going to add MatchedTransform
; it's similar.
There are more techniques calculation TF: "Impulse invariance" and "TF from bode plot"... But Z-transform seems to be the most interesting topic...
Actually, the entire TransferFunction
class is about Z-transform. Z-transform is the mechanism for switching between time-domain difference equations (LTI filter coefficients) and Z-domain (in particular, frequency domain). Some of the tasks are practical and they can be done with NWaves (e.g., TF combinations, zeros\poles analysis, decomposing systems to SOS). However, this lib is not intended for calculus in general.
OK got it. Thank you very much! You are excellent! I will now learn "Transfer Function Analysis" first ...
No problem, you're welcome ) Also, maybe this repo https://github.com/ar1st0crat/DigitalSignalProcessing will be helpful. (There's a couple of old errors there, though. But I tried to make it quite simple and readable)
Can TransferFunction.StateSpace and TransferFunction.Zi be used for methods like Scilab's imrep2ss and frep2tf?
Currently, no. It's again related to MATLAB tfest
function for TF estimation from frequency/impulse response, involving some optimization algorithm. It's not implemented yet...
Is it possible to convert a filter impulse response into a transfer function? Can this be done with the class "TransferFunction"?
https://www.dsprelated.com/freebooks/filters/Transfer_Function_Analysis.html https://de.mathworks.com/help/signal/ug/filter-implementation-and-analysis.html