close all
clear all


data = load('StabPole_3_machine.log');

unix_time = data(:,1);
PropGain = data(:,2);
IntGain = data(:,3);
DerGain = data(:,4);
PitchTarg = data(:,5);
Pitch = data(:,7);
Cmd = data(:,9);
Vout = data(:,10);
mode = data(:,11);
Amp = data(:,12);
Freq = data(:,13);

t = unix_time-unix_time(1);  %Convert to seconds since start of program
dt = t(end)/length(t);

PitchVel = [0 ; diff(Pitch)./diff(t)];


time = unix_time;



figure
ah1 = subplot(3,1,1)
plot(t,PitchTarg);
hold all
plot(t,Pitch);
legend('Pitch Target','Pole Pitch');
ylabel('Degrees');
xlabel('time');
grid on;

PitchVelTarg = [0 ; diff(PitchTarg)./diff(t)];
ah2 = subplot(3,1,2);
plot(t,PitchVelTarg);
ylabel('deg/sec');
xlabel('time');
grid on;

ah3 = subplot(3,1,3);
plot(t,Vout);
ylabel('Valve Command Voltage (V)');
xlabel('time');
grid on;



linkaxes([ah1 ah2 ah3],'x');

