1 % ===============================================================================
2 % optiPIDfun Lukas Reichlin July 2009
3 % ===============================================================================
5 % Reference: Guzzella, L. (2007) Analysis and Synthesis of SISO Control Systems.
6 % vdf Hochschulverlag, Zurich
7 % ===============================================================================
9 function J = optiPIDfun (C_par)
12 global P t dt mu_1 mu_2 mu_3
14 % Function Argument -> Controller Parameters
19 % PID Controller with Roll-Off
20 C = optiPIDctrl (kp, Ti, Td);
25 % Sum Block: e = r - y
26 SUM = ss ([1, -1]); % Matlab converts to SS (and back) for MIMO TF connections
28 % Group Sum Block and Open Loop
29 SUML = append (SUM, L);
31 % Build System Interconnections
32 CM = [3, 1; % Controller Input with Sum Block Output
33 2, 2]; % Sum Block Negative Input with Plant Output
35 inputs = [1]; % Input 1: reference r(t)
36 outputs = [1, 2]; % Output 1: error e(t), Output 2: output y(t)
38 SUML = connect (SUML, CM, inputs, outputs);
41 [y, t_y] = step (SUML, t);
44 itae = dt * (t_y.' * abs (y(:, 1)));
51 J = mu_1 * itae + mu_2 * (max (y(:, 2)) - 1) + mu_3 * Ms;
55 % ===============================================================================