% Define the transfer function model tau = 0.5; % time delay parameter s = tf('s'); Gp = exp(-tau*s)/s^2; % transfer function G % Calculate the crucial gain Kc %phi_des = 63.4; % desired phase margin in degrees %wgc = 1/tau; % gain crossover frequency %alpha = (1+sin(deg2rad(phi_des)))/(1-sin(deg2rad(phi_des))); % Kc = alpha*wgc^2; Kc = 0.707; % Design the controller using the DDCD method Kp = 0.6*Kc; % proportional gain Td = 0.5*(tau+0.1*tau); % derivative time constant Kd = (Td*Kp)/0.1; % derivative gain C = pid(Kp,0,Kd); % PD controller setpoint = 2; % define a setpoint for the controller. % Compute the closed-loop transfer function Gcl = feedback(C*Gp,1); Gcl_sp = setpoint*Gcl; % Plot the step response of the closed-loop system with setpoint step(Gcl_sp);