close all; clc; clear all;

T = 0.1; tau = 0.21; kp = 3; ki = 2; kd = 9;

Fc = tf([(kp*tau + kd) (kp + ki*tau) ki],[tau 1 0])
Fd = c2d(Fc,T,'Tustin')

d2 = 4*(kp*tau + kd) + 2*(kp + ki*tau)*T + ki*T*T;
d1 = 2*ki*T*T -8*(kp*tau + kd);
d0 = 4*(kp*tau + kd) - 2*(kp + ki*tau)*T + ki*T*T;

c2 = 4*tau + 2*T;
c1 = -8*tau;
c0 = 4*tau - 2*T;

Fz = tf([d2/c2 d1/c2 d0/c2],[1 c1/c2 c0/c2], T)

bode(Fc)
hold all
bode(Fd)
bode(Fz)