clear all
close all

mass = 40;      % kg
area = .1018;   % m^2
Cd = 1.5;       % drag coef
cLin = .1;      % const for linearizing velocity squared term in drag
g = 9.8;        % m/s^2
swDensity = 1027;   %kg/m^3

motorVol = .862;    % cm^3/rev
motorSpeed = 1000;  % rev/min
q = motorVol * motorSpeed * (1/60) * (.01^3);

A1 = mass * g;
B1 = .5 * swDensity * Cd * area * cLin;

s = tf('s');
sys1 = A1 / ((mass*s^2) + (B1*s) + 0)
poles = pole(sys1)

num = A1;
den = [mass B1 0];

sys2 = tf(num, den);

step(sys1*q)

figure
impulse(sys1)

figure 
pzmap(sys1)

figure
bodes(sys1)
figure
margin(sys1)

[gainMargin, phaseMargin, xGainCross, wPhaseCross] = margin(sys1)


