% easy examples - Magnitude Optimum: use of bo_prefi_op02

% plant example: 3 first-order time-delay elements
Vs=0.25;  T1=10; T2=7; T3=1;
plt_num=Vs;
plt_den=conv(conv([T1  1],[T2  1]),[T3  1]);
PLT=tf(plt_num,plt_den);  % LTI plant

% PID controller and pre-filter by MO for delayed inputs:
[Rdel,Fdel,A23,FLAG3]=bo_d_pltgen(3,PLT),

% PID controller by MO for undelayed inputs:
Ru=bo_u_gen(3,Vs,1,plt_den);
Rund=tf([ Ru(4)*Ru(2)  Ru(2)   1 ],[ 0  0  Ru(3)  0 ]),

%optimized pre-filter by MO undelayed inputs and MO delayed inputs:
FIL_OP1b=bo_prefi_op02(PLT,Rund,tf(1,1),Rdel,Fdel,3),

% PID controller and pre-filter by Naslin for delayed inputs:
R2=dr_d_wedz(1,Vs,T1,T2,T3),   R2parvec=[ R2{1,3}*R2{1,2}   R2{1,2}   1 ],
Rdra = tf(R2parvec,[ 0  R2{2,3}  0]),
Fdra = tf(1       ,R2parvec),

%optimized pre-filter by Naslin method and MO delayed inputs:
FIL_OP2=bo_prefi_op02(PLT,Rdra,Fdra,Rdel,Fdel,3),

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