# dfan.m - ducted fan computations
# RMM, 24 Oct 94

# System parameters (see hw #0)
J = 0.0475
m = 1.5
r = 0.25 
g = 10
d = 0.1
l = 0.05

# Transfer function for pitch
Pnum = [r];
Pden = [J 0 m*g*l];

# Design a simple lead (PD) controller for the system
k = 15;
a = 25;
b = 300;

Cnum = k*[1 a];
Cden = [1/b 1];

[Lnum, Lden] = series(Cnum, Cden, Pnum, Pden);
[numc, denc] = cloop(Lnum, Lden, -1);
rlocus(Lnum, Lden);
axis([-300 300 -80 80]);
title('Root Locus Plot for Ducted Fan Pitch Controller')
print('pitch-rootloc.ps');

# Plot the step response just to see how it looks
T = [0:100]/200;
[y, x] = step(numc, denc, T);
plot(T,y);
xlabel('Time (sec)');
ylabel('Pitch angle (rad)');
title('Step Response for Ducted Fan Pitch Controller');
print('pitch-stepresp.ps');
