% Magnitude Optimum controller parameters for Pp_t1ex4_sim.slx
% plant and book parameters: PID Controller Tuning Using the Magnitude 
% Optimum Criterion, by K.G. Papadopoulos, Springer 2015, example page 51,
% equation (3.81), (3.82a/c) and idea page 75, equation (3.146)in turn

Vs=1;
nump1=conv([-0.9 1],[-0.7 1]);
nump2=conv([-0.7 1],[-0.5 1]);                 % for comparison only
nump3=conv([-0.6 1],conv([-0.4 1],[-0.2 1]));  % in turn to book only
denop=conv([1 1],conv([1 1],conv([1 1],conv([1 1],[1 1]))));

REGu1            =bo_u_gen(13,Vs,nump1,denop);
REGu2            =bo_u_gen(13,Vs,nump2,denop);  % for comparison only
REGu3            =bo_u_gen(13,Vs,nump3,denop);

[REGd1,A11,F11]=bo_d_gen(13,Vs,nump1,denop);
[REGd2,A12,F12]=bo_d_gen(13,Vs,nump2,denop);    % for comparison only
[REGd3,A21,F21]=bo_d_gen(13,Vs,nump3,denop);

REG51_75(4:6,:  )=[REGd1; REGd2; REGd3];  %length=4
REG51_75(1:3,1:5)=[REGu1; REGu2; REGu3],  %length=5

disp('"Pp_t1ex4_sim.slx" will be called - compare parameters')
Pp_t1ex4_sim; sim('Pp_t1ex4_sim',160),
disp('Repeat bo_d_gen call at MATLAB promt, if search algorithm fails')
