%PID Tuning
K=0.7; taua=2; tauad=0.6; % OL plant response

% Cohen-Coon PID
Kp1=(taua/(K*tauad)) * ( 4/3 + tauad/(4*taua))
Ti1=tauad*((32+6*tauad/taua)/(13+8*tauad/taua))
Td1=tauad*(4/(11+2*tauad/taua))

% ITAE PID
sp1=1.357; sp2=-0.947;
si1=0.842; si2=-0.738;
sd1=0.381; sd2=0.995;
r=tauad/taua;

Kp2=sp1*r^sp2
Ti2=si1*r^si2
Td2=sd1*r^sd2

sim pidsim; % calls simulink block

plot(tout,y,'k',tout,y1,'k',tout,y2,'k');  % draw step response
xlabel('time[s]'); ylabel('y(t), y_1(t), and y_2(t)'); grid on;
%legend('y(t) OL plant','y_1(t) Cohen-Coon','y_2(t) ITAE');