% inspired by Papadopolous, page73: (3.143) and page74: (3.145)
Vs=1;
nump=[-2  1];
     denph1=conv([4  1],[4  1]);
     denph2=conv([1  1],conv([1  1],conv([1  1],[1  1])));
denp=conv(denph1,denph2);
SP4=tf(nump,denp),

Regu3=bo_u_gen(13,Vs,nump,denp), %PID
Regd3=bo_d_gen(13,Vs,nump,denp), %PID
       
%z-transform of the plant; sampling time T=0.5ms;
T=0.5;   [zz,nz]=trans(nump,denp,T,0,1); SZ4=tf(zz,nz,T),

SV3=[0 0 0 0 2 2];        BODu4=bod(SZ4,SV3),   % PID undel
SV8=[1 0 0 0 2 2]; [BODd4,FId4]=bod(SZ4,SV8),   % PID delayed

Pla=SZ4;  C_ref=BODu4;,   PFi_ref=tf(1,1,T);
          C_sys=BODd4;    PFi_sys=FId4;
OPF_PID2 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys),
OPF_PID3 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys,3),
OPF_PID4 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys,4),

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