%Cvejn, J.: The magnitude optimum design of the PI controller for plants 
%with complex roots and dead time. Archives of Control Sciences, vol. 32, 
%no. 1, pp. 5-35, 2022; plant examples: number 1 till 4, controllers: PID

p1den=[            1                 1 ];           p1dt=0.1;
p1denMP=conv([ 1  1 ],[0.01  1]);
p2den=  conv([ 1  1 ]                ,[ 0.2   1 ]); p2dt=0;
p2denMP=conv(conv([ 1  1 ],[ 0.2 1 ]),[ 0.01  1 ]);
p3den=[ 0.4907^2   2*0.8660*0.4907   1 ];           p3dt=0.05;
p4den=[ 0.4950^2   2*0.7071*0.4950   1 ];           p4dt=0.2;

% controller parameter sequence: VR_TN_TR0_TV
R1ugen=bo_u_gen(13,1,1,p1denMP,p1dt,19),
R2ugen=bo_u_gen(13,1,1,p2denMP),
R3ugen=bo_u_gen(13,1,1,p3den,  p3dt,19),
R4ugen=bo_u_gen(13,1,1,p4den,  p4dt,19),

       optim=optimset('MaxFunEvals',8000,'MaxIter',4000); % case 2
R1dgen=bo_d_gen(13,1,1,p1denMP,p1dt,19,[],optim),
R2dgen=bo_d_gen(13,1,1,p2denMP,[],  [],[],optim),
R3dgen=bo_d_gen(13,1,1,p3den,  p3dt,19,[],optim),
R4dgen=bo_d_gen(13,1,1,p4den,  p4dt,19),

cv_PID_1till4_sim; sim('cv_PID_1till4_sim',20)
