Yes, I am very sure. In fact, removing zero and near-zero elements introduces a bug.
Note how both a_out and b_out are polynomials. Taking an element out,
will shift the polynomial weights to the next power, messing up the
entire polynomial. The results will be both bizarre and difficult to
track down, because of their random nature.
included a number of test cases for both impinvar and invimpinvar. The
tests are based on calculating the impulse response of the
continuous-time system and the equivalent discrete-time system. They
include some extreme cases, with poles of multiple order, multiple
complex poles and complex residues. As the name suggests, the impulse
invariance transform should give exactly the same results for both
systems at the sample times n*ts. With the proposed changes, the two
routines pass all 24 tests. Sure enough, when changing the two lines to
remove small values, impinvar will fail.
for each of the 12 impinvar cases, the results exactly matches the
Matlab result (Matlab does not have the inverse impulse invariance
Hope this helps, let me know if you need any additional information.
From: Carnë Draug <carandraug+dev@...>
To: Rudy Eschauzier <reschauzier@...>
Cc: Juan Manuel Parrilla Gutiérrez <joanmanel@...>; "octave-dev@..." <octave-dev@...>
Sent: Tuesday, October 11, 2011 1:14 PM
Subject: Re: [OctDev] Impulse invariance transform implementation
2011/10/10 Rudy Eschauzier <reschauzier@...>:
> Attached are updated files for the impulse invariance transform and its
> inverse. I have also attached a diff file against the current svn revision.
> These are the changes:
> -impinvar and invimpinvar now include test cases.
> -bug fixes
> -code optimization (vectorization)
> Please let me know if you have any questions.
I noticed that on your update, you make the following change
## respect the required tolerance values
- b_out(abs(b_out)<tol) = ;
- a_out(abs(a_out)<tol) = ;
+ b_out(abs(b_out)<tol) = 0;
+ a_out(abs(a_out)<tol) = 0;
previously, the code would remove/truncate values below the tolerance
value, but your change only turns them into zero. Is this compatible
with matlab's impinvar? I do not have access to any machine with
matlab so I only googled for classes online using impinvar and the
expected results to mimic this. Are you sure of this change?