% Define the time delay and Laplace variable tau = 1.5; s = tf('s'); % Define the transfer function G = exp(-tau*s)/(s^2); % Set up the PID controller with automatic tuning C = pidtune(G,'PID'); % Define the setpoint value setpoint = 3; % Define random disturbance rng(0); % set seed for reproducibility M = rss(3,1,1); % generate 3x1 random matrix with damping=1 and natural frequency=1 % Set up the PID controller with automatic tuning to get the disturbance signal C2 = pidtune(M,'PID'); % Plot the closed-loop response with setpoint T_total = feedback(G*C*C2,1); step(setpoint*T_total);