% check for bod_prefi_opt

% example taken from DEMO_BOD.m
%plant definition in Laplace domain (two first-order time delay elements)
%using gain V=1 and time constants T1=8ms, T2=2ms):
z=1; n=[16 10 1];
%z-transform of the plant; sampling time T=2ms;
T=2; [zz,nz]=trans(z,n,T,0,1)
disp('pause - press any key please');
pause,     %press any key please

%LTI model in Laplace-domain
SP1=tf(z,n),
%LTI model in z-domain (advantageously by negative powers of z):
SZ1=tf(zz,nz,T,'Variable','z^-1'),
disp('pause - press any key please');
pause,     %press any key please

%A3, PID-type controller (undelayed input signals)
%                                                 without pole compensation
SV3=[0 0 0 0 2]; RE3=bod(SZ1,SV3),
disp('pause - press any key please');
pause,     %press any key please

%B3, PID-type controller and pre-filter (delayed input signals) 
%                                                 without pole compensation
SV8=[1 0 0 0 2 1]; [RE8,FI8]=bod(SZ1,SV8),
disp('pause - press any key please');
pause,     %press any key please

Pla=SZ1;  C_ref=RE3;,   PFi_ref=tf(1,1,T);
          C_sys=RE8;    PFi_sys=FI8;
OpPreFil_2 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys),
OpPreFil_3 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys,3),
OpPreFil_4 = bod_prefi_opt(Pla,C_ref,PFi_ref,C_sys,PFi_sys,4),

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