%lecture7 cruise design using lag compensator.
%____________________
%step 1
m = 1000;
b = 50;
u = 500;
Kp=1;

numo=[Kp];
deno=[m b];

step (u*numo,deno)
%____________________
%step 2

bode(numo,deno) 
%____________________
%step 2a closed loop
[numc,denc]=cloop(numo,deno)
step(10*numc,denc)

%____________________
%step 3
m = 1000;
b = 50;
u = 10;
Kp=100;

numo=[Kp];
deno=[m b];

bode(numo,deno)
%____________________
%step 3a closed loop
[numc,denc]=cloop(numo,deno)
step(10*numc,denc)


%____________________
%step 4
m = 1000;
b = 50;
u = 10;
Kp=600;

numo=[Kp/b];
deno=[m/b 1];

bode(numo,deno)
%____________________
%step 4a closed loop
[numc,denc]=cloop(numo,deno)
step(10*numc,denc)

%____________________
%step 5
m = 1000;
b = 50;
u = 10;
Kp=600;

numo=[Kp/b];
deno=[m/b 1];

a = 0.05;
T=700;
numlag = [a*T 1];
denlag = a*[T 1];
newnum = conv(numo,numlag);
newden = conv(deno,denlag);

bode(newnum,newden)

figure
[numc,denc]=cloop(newnum,newden);
step (u*numc,denc)

%____________________
%step 6
m = 1000;
b = 50;
u = 10;
Kp=1500;

numo=[Kp/b];
deno=[m/b 1];

a = 0.05;
T=700;
numlag = [a*T 1];
denlag = a*[T 1];
newnum = conv(numo,numlag);
newden = conv(deno,denlag);

bode(newnum,newden)

figure
[numc,denc]=cloop(newnum,newden);
step (u*numc,denc)
