MATLAB polystab function: It doesn't seem to be doing anything!

I've been attempting to stabilise an unstable filter (unfortunately, I cannot redesign the filter in a way that it is more stable and that is NOT an option). It is derived from an approximation of actual physical components, which I know very little about, and certain fixed values for those are used to obtain a LaPlace domain equation. This is then put through the bilinear transform and we get digital filter coefficients. I apologize for the lack of code as I simply cannot post it here; there are 4 parameters that control the generation of the s-domain filter transfer function. The program loops through all parameter values and generates coefficients for each configuration.

As you will see here, I even tried to inline the polystab implementation (the lines that are commented out), and I can see the roots of the denominator (ie, the poles) being greater than or equal to 1. After reflecting them back inside the unit circle you can see the poles are now less than 1. I've checked my syntax for passing on the polynomial coefficients to polystab multiple times, and I'm sure the syntax is correct. As seen in the attached pictures, the result of polystab doesn't change anything. Is there something fundamental that I just can't see? Even the result of isstable remains 0 even after putting the denominator polynomial through polystab. HELP!


result = isstable( numD, denD );
% result = stabilitycheck( denD' );

if result == 0

% for roots calculation denD needs to be flipped, for
% polystab it is fine as is.

%arr = flip(denD);
%v = roots(arr);
%vs = 0.5*(sign(abs(v)-1)+1);
%newv = (1-vs).*v + vs./conj(v);
%newconfig = arr(1) * poly(newv);

newconfig = polystab(denD);

scale = abs( sum(newconfig) / sum(denD) );
numD = numD .* scale;

res = isstable(numD, newconfig);

if( res == 0 )
err_config(index, :) = [ B M T I ];
index = index + 1;
end

end

end

end

end

end

• Is denD a polynomial in the s-domain or in the z-domain? Commented Jul 13, 2022 at 7:52
• Hello Matt, denD contains the z-domain coefficients; all the coefficient data from the pictures is in the z-domain. Cheers! Commented Jul 13, 2022 at 9:02

The coefficients denD shown in the table correspond to a polynomial with a zero at $$z=1$$, resulting in a marginally stable filter if used as the denominator polynomial of the transfer function. Reflecting poles across the unit circle circle - which is what polystab does - won't help because there's no pole outside the unit circle, just right on the unit circle.
What you can do is move the pole at $$z=1$$ slightly inside the unit circle, i.e., replace it with a pole at $$z=r$$, $$0\ll r<1$$, and compute the corresponding polynomial coefficients using poly.
• @Kartikeya: Yes, if you have a real-valued pole at (or close to) $z=1$, just replace it by a pole at $z=r$ with $r$ close to (but smaller than) $1$. Commented Jul 13, 2022 at 13:44