close all
clear all

data = load('test4_mon_machine');

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);

t = unix_time-unix_time(1);  %Convert to seconds since start of program
dt = t(end)/length(t);
time = dt*(0:length(t)-1)';  %Smooth out time bumps, it's not clear why there's a periodic time advancement/delay recorded in the data.

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

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

ah2 = subplot(4,1,2)

plot(time,PitchVel);
ylabel('Pitch Velocity (deg/s)');
xlabel('time (sec)');
grid on;

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

ah4 = subplot(4,1,4);
plot(time,PropGain);
hold all;
plot(time,IntGain);
plot(time,DerGain);
legend('Prop Gain','Int Gain','Der Gain');
xlabel('time (sec)');
grid on;


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






