MATLAB: How the series of 2 stable discrete-systems becomes unstable

bode diagramControl System Toolboxdiscrete systemsstabilitysystems series

Hello everyone,
I am currently struggling to understand why if I do the series of these two STABLE discrete-systems, the resulting system is UNSTABLE.
tECU = 0.001;
z = tf('z', tECU);
opts = bodeoptions;
opts.FreqUnits = 'Hz';
%% HP filter simple
G1 = tECU/(tECU+0.1*2*pi);
HP1 = (z-1)/(z-1+G1);
%% HP filter 4th order
B1 = 0.999326955592380;
B2 = -3.997307427851055;
B3 = 5.995960944517369;
B4 = -3.997307427851056;
B5 = 0.999326955592380;
A1 = 1.000000000000000;
A2 = -3.998653063327113;
A3 = 5.995960491528685;
A4 = -3.995961792374911;
A5 = 0.998654364173536;
HP4 = (z^4*B1 + z^3*B2 + z^2*B3 + z*B4 + B5)/(z^4*A1 + z^3*A2 + z^2*A3 + z*A4 + A5);
%% poles
p1 = pole(HP1);
p2 = pole(HP4);
p_tot = pole(HP1*HP4);
%% plot Pole-Zero map
figure; hold on;
pzmap(HP1, HP4, HP1*HP4, opts);
legend('HP1','HP1*HP4','HP4');
Both HP1 and HP4 have stable poles, but when I do the series of HP1 and HP4 Matlab says that the resulting system has an unstable pole. Furthermore, all the poles and zeros seems to change position.
Any help or suggestion is appreciated.
Thanks

Best Answer

I think you are seeing some roundoff or other numerical issues. Higher order polynomials (in your case a 5th order polynomial) are notorious for having behavior that is very sensitive to coefficient values. The poles of your original two transfer functions are already close to zero. I think you also may have a problem in your HP4 in that the zeros and poles are all very close to 1, basically you have very close (Z-1)^4/(Z-1)^4 so the near pole zero cancellation may also be causing you numerical issues.
I would recommend looking more closely at you filter design, do you really want the zeros and poles to be nearly identical?
Also for future reference you can much more simply define your second transfer function using:
HP4 = tf([B1 B2 B3 B4 B5],[A1 A2 A3 A4 A5],tECU)
rather than expanding the polynomial yourself