clear all;
close all;

shipname = 'Red Herring 1';
filnavn = strcat(shipname,'-Log.csv');

%Rå dataindlæsning
[Data,ffn,nh,SR,hl,fpos] = txt2mat(filnavn,1);

%Fikser bredden på data
h_bred = size(Data);
h_bred = h_bred(2);

%Rå og brutal deling ad data i tekstfelter
headers = textscan(hl,'%s',h_bred*nh,'delimiter',',');
headers = headers{1};

%Headers har kolonnetitler
%Data har data

x = (Data(:,1) - min(Data(:,1))) ./ 60;

%Diverse kolonner sættes
acc = Data(:,4)./Data(:,5); %thrust./mass
alt = Data(:,2) ./ 1000;
vel = Data(:,6) ./ 1000;
ang = Data(:,3);
%acc2 = Data(:,7);


%Dual figure
figure;
subplot(2,1,1);
hold on;
grid on;
title(strcat(shipname,' Ascent'));

yyaxis left;
plot(x,acc);
ylabel('Acceleration [m/s^2]');

yyaxis right;
plot(x,vel);
ylabel('Velocity [km/s]');
 
subplot(2,1,2);
hold on;
grid on;

xlabel('Mission time [min.]');

yyaxis left;
plot(x,alt);
ylabel('Altitude [km]');

yyaxis right;
plot(x,ang);
ylabel('Angle above horizon [°]');

filnavn = strcat(shipname,'-Log.png');
print('-dpng',filnavn);

%Apollo figure
figure;
hold on;
grid on;
xlabel('Mission time [min.]');
title(strcat(shipname,' Ascent'));
yyaxis left;
plot(x,acc./9.82,'r');
%plot(x,acc2,'r');
plot(x,vel,'g')
ylabel('{\color{red}Acceleration [g]} / {\color{green}Velocity [km/s]}');

yyaxis right;
plot(x,alt,'b');
ylabel('{\color{blue}Altitude [km]}');

filnavn = strcat(shipname,'-Single-Log.png');
print('-dpng',filnavn);

close all;