format compact; echo on;
%DEMO_SIMU - application example for simu.m:
%Fast check of discontinuous controllers without SIMULINK

%plant definition (Laplace domain) + controller calculation (discontinu./z-domain):
z=1; n=conv(conv([2 1],[4 1]),[7 1]);  %plant: numerator and denominator definition
T=2.5; [zz,nz,sdef]=trans(z,n,T,0,2);             %cp. DEMO_BOD or help trans.m
[rz,rn,fz,fn]=bod(zz,nz,[1 1 0 1 1 2]); echo off, %cp. DEMO_BOD or help bod.m
disp('numerator and denominator polynomial of prefilter and controller:');
fz,fn,rz,rn, echo on
pause,           %press any key please

%setpoint step response: simulation and quality criteria calculation using simu.m
%please conform with input commands:
zs0=1;       %no additional disc. numerator polynomial between controller and plant
wv=ones(1,40);  wv(1)=0;  %setpoint vector; step not identical with axis 
zv=zeros(1,40);           %disturbance variable vector; no change
[AM1,t,vx,vy,vw2,vz,vq]=simu(fz,fn,rz,rn,zs0,sdef,wv,zv); echo off
disp('packed quality criteria: analysis see help simu.m');
disp('                         time values refered to step point');
if length(AM1)~=1 AM1, 
else disp('quality criteria calculation was not selected'); end
echo on;
pause,           %press any key please

%disturbance variable step response: simulation/quality criteria calc. using simu.m
%please conform with input commands:
zs0=1;       %no additional disc. numerator polynomial between controller and plant
wv=zeros(1,40);         %setpoint vector; no change
zv=ones(1,40); zv(1)=0; %disturbance variable vector; step not identical with axis
[AM2,t,vx,vy,vw2,vz,vq]=simu(fz,fn,rz,rn,zs0,sdef,wv,zv); echo off
disp('packed quality criteria: analysis see help simu.m');
disp('                         time values refered to step point');
if length(AM2)~=1 AM2,
else disp('quality criteria calculation was not selected'); end
clear z n zs0 T zz nz rz rn fz fn AM1 AM2 t vx vy vw2 vz vq
