I have a feedback loop with transfer $L(z)= \frac{H(z)C(z)}{1+H(z)C(z)}$.
$$H(z) = h\quad \text{and} \quad C(z) = \frac{K}{z-\alpha}.$$
If I manually calculate the transfer function, I get:
$$L(z) = \frac{Kh}{z-\alpha + Kh}$$
But if I let MATLAB do the calculation I get:
$$L(z) = \frac{z-\alpha}{z-\alpha}\frac{Kh}{z-\alpha + Kh}$$
$L(z)$ is unstable with $\alpha=2$ and $K=\frac{1}{h}$. The second transfer function (calculated with MATLAB) has two poles $(1,2)$ of which one is outside the unit circle. So the second one seems to be correct. What is wrong with the first one?
z = tf('z',-1)
means you've created a discrete time system with a sampling rate of -1. That seems wrong. Quote:z = tf('z',Ts) to specify a TF model with sample time Ts using a rational function in the discrete-time variable, z.
$\endgroup$