
if ~isdef("data") & isdef("filePrefix");
	data=fscanfMat(filePrefix + ".txt");
end;

time = data(:,4);
alt = data(:,7) *3.2808399;

//find mode of data, which is probably the ground
nBins=100;
a0 = min(alt);
a1 = max(alt);
da = (a1 - a0) / (nBins - 1);
bestN = - %inf;
groundAlt = %nan;
for i=1:nBins;
	n = length(find(alt >= (a0 + i*da) & alt < (a0 + i*da + da)));
	if n > bestN;
		bestN = n;
		groundAlt = a0 + i*da + da/2;
	end;
end;

height = alt - groundAlt;
h0 = a0 - groundAlt;
h1 = a1 - groundAlt;

t0=min(time);
t1=max(time);
airbourne = find(height > 300);
tLaunch = time(airbourne(1)) - (10/60);
tLand = time(airbourne($)) + (30/60);

clf;
plot(data(:, 4), alt, "b");
plot([tLaunch, tLaunch], [a0 ,a1], "--k");
plot([tLand, tLand], [a0 ,a1], "--k");

axA = gca();

axH=newaxes();
plot(data(:, 4), height, "b");
plot([t0, t1], [0 ,0], "--k");


axH.y_location="right";


f=gcf();
f.pixel_drawing_mode="and";

axA.data_bounds = [tLaunch - (120/60), a0; tLand + (120/60), a1];
axH.data_bounds = [tLaunch - (120/60), h0; tLand + (120/60), h1];
axA.tight_limits="on";
axH.tight_limits="on";

axA.y_label.text = "Altitude (QNH) / ft";
axH.y_label.text = "Height (QFE) / ft";

axA.title.text = "flight time ~ " + string(tLand - tLaunch) + " mins";
axA.x_label.text = "time / mins";
