clc

A = readtable('B17.10.17.xlsx','Range','A2:AD72359');             % definiert die Tabelle


x = A {:, 1};                         % Datum/Zeit
y = A {:, 2};                         % Druck in bar Parr
x1 = A {:, 3};                        % Datum/Zeit
y1 = A {:, 4};                        % Druck in bar Wika
x2 = A {:, 5};                        % Datum Zeit
y2 = A {:, 6};                        % Temperatur in °C Star oddy 71
x3 = A {:, 5};                        % Datum Zeit
y3 = A {:, 7};                        % Druck in bar Star oddy 71
x4 = A {:, 8};                        % Datum Zeit
y4 = A {:, 9};                        % Temperatur in bar Star oddy 69
x5 = A {:, 8};                        % Datum Zeit
y5 = A {:, 10};                       % Druck in bar Star oddy 69
x6 = A {:, 11};                        % Datum Zeit
y6 = A {:, 12};                        % Bronckhorst Maxflow [%]
x7 = A {:, 11};                        % Datum Zeit
y7 = A {:, 13};                        % Bronckhorst Flow [nm3/ds]
x8 = A {:, 11};                        % Datum Zeit
y8 = A {:, 14};                        % Bronckhorst Cumulativ Flow [nm3]
x9 = A {:, 15};                        % Datum Zeit
y9 = A {:, 16};                        % Isco Pressure A
x10 = A {:, 15};                       % Datum Zeit
y10 = A {:, 17};                       % Isco Flowrate A
x11 = A {:, 15};                       % Datum Zeit
y11 = A {:, 18};                       % Isco Volume A
% x12 = A {:, 15};                       % Datum Zeit
% y12 = A {:, 19};                       % Isco Pressure B
% x13 = A {:, 15};                       % Datum Zeit
% y13 = A {:, 20};                       % Isco Flowrate B
% x14 = A {:, 15};                       % Datum Zeit
% y14 = A {:, 21};                       % Isco Volume B
% x15 = A {:, 15};                       % Datum Zeit
% y15= A {:, 22};                        % Isco Pressure C
% x16 = A {:, 15};                       % Datum Zeit
% y16= A {:, 23};                        % Isco Flowrate C
% x17 = A {:, 15};                       % Datum Zeit
% y17= A {:, 24};                        % Isco Volume C
x18 = A {:, 25};                       % Sandproduciton time
y18 = A {:, 26};                       % Sandproduction cumulative
x19 = A {:, 25};                       % Sandproduciton time
y19 = A {:, 27};                       % Sandproduction rate
x20 = A {:, 15};                         % Cumulative Isco time
y20 = A {:, 29};                         % Cumulative Isco Volume
x21 = A {:, 15};                         % Cumulative Isco time
y21 = A {:, 30};                         % Piston Way in [cm]



f1 = figure ('NumberTitle','off','Name','Dry High Flow',...
'Color','w','Resize','on','Units','normalized','Position',[0 0 1 1]);          % Abbildung keine Nummer im Titel,Titel, Hintergrundfarbe: weiß
left_color = [0 0 0];                                                          % linke y-Achse schwarz
right_color = [0 0 0];                                                         % rechte y-Achse rot
set(f1,'defaultAxesColorOrder',[left_color; right_color]);                     % definiert das Farbschema für die Abbildung



ax1 = subplot (4,1,1);                                                         % (4,1,1) = 4 Graphics,1 column,1 Position/Order  Funktioniert nur so lange wie man die Positionen der Graphen nicht einzeln definiert
ax2 = subplot (4,1,2);                            
ax3 = subplot (4,1,3);                            
ax4 = subplot (4,1,4);


%PLOT 1
yyaxis (ax1,'left')                                                            % linke y-Achse und alle dazugehörigen Daten 

plot(ax1,x,y,x1,y1,x3,y3,'Linewidth',.9);                                % Daten input, Linienstärke in Pixeln
% title(ax1,'Pressure');                                                       % Titel
xlabel(ax1,'Time []');                                                       % Titel x-Achse
ylabel(ax1,'Pressure [bar]','FontSize',12,'Color','k');                        % Titel y-Achse, Schriftgröße, Farbe
% ylim(ax1, [0 125])


yyaxis (ax1,'right')                                               % rechte y-Achse und alle dazugehörigen Daten
plot (ax1,x21,y21,'Color', rgb ('Crimson'),'LineWidth',.9)  
ylabel(ax1,'Displacement [cm]','FontSize',12,'Color', rgb('Crimson')) 
ylim(ax1, [0 25])                                                  % definiert den angezeigten Bereich der y-Achse



% tstart = datetime (2017,10,17,00,00,00);                         % Startzeit Intervall (Jahr,Monat,Tag,Stunde,Minute,Sekunde)
% tend = datetime (2017,10,18,00,00,00);                           % Endzeit Intervall (Jahr,Monat,Tag,Stunde,Minute,Sekunde)
% xlim(ax1,[tstart tend]);                                         % Intervall x-Achse
                                      

set(ax1, 'Units', 'normalized');                                                  % definiert die Einhaltung der Einheiten
set(ax1, 'Position', [0.25 0.78 0.5 0.20]);                                        % Verschiebung links unten Breite Höhe
% set(ax1, 'xticklabel',{[]});                                                      % entfernt die x-Achsen Beschriftung

annotation('textbox',[0.2505 0.957 0.015 0.023],'String','\bf A','FitBoxToText','off',...
           'FontSize',12,'FontName','Arial', 'HorizontalAlignment','center',...
           'VerticalAlignment','middle','LineStyle','-','EdgeColor','k','Margin',0.01,...
           'LineWidth',1,'BackgroundColor','k','Color','w','Units','normalized');
       
dim = [0.698 0.78 0.01 0.1989];
annotation('rectangle',dim,'Color','k','Units','normalized','LineWidth',2)    


%PLOT 2 Zoom
yyaxis (ax2,'left')                                                % linke y-Achse und alle dazugehörigen Daten 

plot(ax2,x,y,x1,y1,x3,y3,'LineWidth',.9);                    % Daten input, Linienstärke in Pixeln
% title(ax2,'Pressure');                                           % Titel
% xlabel(ax2,'Time []');                                           % Titel x-Achse
% ylabel(ax2,'Pressure [bar]','FontSize',12,'Color','k');            % Titel y-Achse, Schriftgröße, Farbe
ylim(ax2, [0 125])

ax2.XColor = 'k';
ax2.YColor = 'k';
ax2.LineWidth = 2;

yyaxis (ax2,'right')                                               % rechte y-Achse und alle dazugehörigen Daten
plot (ax2,x21,y21,'Color', rgb ('Crimson'),'LineWidth',.9)  
% ylabel(ax2,'Displacement [cm]','FontSize',12,'Color', rgb('Crimson')) 
ylim(ax2, [0 25])                                                  % definiert den angezeigten Bereich der y-Achse


ax2.XColor = 'k';
ax2.YColor = 'k';
ax2.LineWidth = 2;

tstart = datetime (2017,10,17,10,15,00);                         % Startzeit Intervall (Jahr,Monat,Tag,Stunde,Minute,Sekunde)
tend = datetime (2017,10,17,10,50,00);                           % Endzeit Intervall (Jahr,Monat,Tag,Stunde,Minute,Sekunde)
xlim(ax2,[tstart tend]);                                         % Intervall x-Achse
                                      

set(ax2, 'Units', 'normalized');                                                  % definiert die Einhaltung der Einheiten
set(ax2, 'Position', [0.45 0.53 0.30 0.20]);                                        % Verschiebung links unten Breite Höhe
% set(ax2, 'xticklabel',{[]});                                                      % entfernt die x-Achsen Beschriftung

% annotation('textbox',[0.1005 0.946 0.015 0.023],'String','\bf A','FitBoxToText','off',...
%            'FontSize',12,'FontName','Arial', 'HorizontalAlignment','center',...
%            'VerticalAlignment','middle','LineStyle','-','EdgeColor','k','Margin',0.01,...
%            'LineWidth',1,'BackgroundColor','k','Color','w','Units','normalized');
%        
% dim = [0.6175 0.72 0.02 0.2489];
% annotation('rectangle',dim,'Color',rgb('DarkSlateGrey'),'Units','normalized','LineWidth',1.1)
       
%PLOT 3

yyaxis (ax3,'left') 

plot(ax3,x7,y7,x8,y8','LineWidth',.9);
% title (ax3, 'Temperature');
% xlabel (ax3,'Time []');
ylabel (ax3,'Flow [nm^3]','FontSize',12,'Color','k');
ylim (ax3,[0 30]);


yyaxis (ax3, 'right');

plot(ax3,x18,y18,'Color',rgb('Crimson'),'Linewidth',.9);
ylabel(ax3,'Sand production [kg]','FontSize',12,'Color', rgb('Crimson'));


% tstart = datetime (2017,10,17,10,00,00);
% tend = datetime (2017,10,17,12,00,00);
% xlim (ax3,[tstart tend]);
ylim (ax3,[0 5]);




set(ax3, 'Units', 'normalized');
set(ax3, 'Position', [0.25 0.28 0.5 0.20]);

annotation('textbox',[0.2505 0.456 0.015 0.023],'String','\bf B','FitBoxToText','off',...
           'FontSize',12,'FontName','Arial', 'HorizontalAlignment','center',...
           'VerticalAlignment','middle','LineStyle','-','EdgeColor','k','Margin',0.01,...
           'LineWidth',1,'BackgroundColor','k','Color','w','Units','normalized');     
       
dim = [0.517 0.28 0.1 0.1989];
annotation('rectangle',dim,'Color','K','Units','normalized','LineWidth',2)       
       
%PLOT 4 zoom

yyaxis (ax4,'left') 

plot(ax4,x7,y7,x8,y8','LineWidth',.9);
% title (ax4, 'Temperature');
% xlabel (ax4,'Time []');
% ylabel (ax4,'Flow [nm^3]','FontSize',12,'Color','k');
ylim (ax4,[0 30]);

ax4.XColor = 'k';
ax4.YColor = 'k';
ax4.LineWidth = 2;

yyaxis (ax4, 'right');

plot(ax4,x18,y18,'Color',rgb('Crimson'),'Linewidth',.9);
% ylabel(ax4,'Sand production [kg]','FontSize',12,'Color', rgb('Crimson'));

ax4.XColor = 'k';
ax4.YColor = 'k';
ax4.LineWidth = 2;


tstart = datetime (2017,10,17,10,36,00);                         % Startzeit Intervall (Jahr,Monat,Tag,Stunde,Minute,Sekunde)
tend = datetime (2017,10,17,10,47,00); 
xlim (ax4,[tstart tend]);
ylim (ax4,[0 5]);




set(ax4, 'Units', 'normalized');
set(ax4, 'Position', [0.45 0.03 0.30 0.20]);

% annotation('textbox',[0.1005 0.646 0.015 0.023],'String','\bf B','FitBoxToText','off',...
%            'FontSize',12,'FontName','Arial', 'HorizontalAlignment','center',...
%            'VerticalAlignment','middle','LineStyle','-','EdgeColor','k','Margin',0.01,...
%            'LineWidth',1,'BackgroundColor','k','Color','w','Units','normalized');     
%        
% dim = [0.6175 0.42 0.02 0.2489];
% annotation('rectangle',dim,'Color',rgb('DarkSlateGrey'),'Units','normalized','LineWidth',1.1)       
 
% FIGURE 2



f2 = figure ('NumberTitle','off','Name','Dry High Flow',...
'Color','w','Resize','on','Units','normalized','Position',[0 0 1 1]);          % Abbildung keine Nummer im Titel,Titel, Hintergrundfarbe: weiß
left_color = [0 0 0];                                               % linke y-Achse schwarz
right_color = [0 0 0];                                              % rechte y-Achse rot
set(f2,'defaultAxesColorOrder',[left_color; right_color]);


ax5 = subplot (1,1,1);

%POLT 5
yyaxis (ax5, 'left');

plot(ax5,x2,y2,x4,y4,'LineWidth',.9);
% title (ax5,'N_2 Flow');
% xlabel (ax5,'Time');
ylabel (ax5,'Temperature [°C]','FontSize',12,'Color','k');
ylim (ax5, [0 35]);


yyaxis (ax5, 'right');
% ylabel(ax5,'Temperature [°C]','FontSize',12);

% tstart = datetime (2017,11,29,12,00,00);
% tend = datetime (2017,11,29,13,00,00);
% xlim (ax5,[tstart tend]);
ylim (ax5,[0 35]);

set(ax5, 'Units', 'normalized');
set(ax5, 'Position', [0.25 0.70 0.5 0.20]);

annotation('textbox',[0.2505 0.876 0.015 0.023],'String','\bf C','FitBoxToText','off',...
           'FontSize',12,'FontName','Arial','HorizontalAlignment','center',...
           'VerticalAlignment','middle','LineStyle','-','EdgeColor','k','Margin',0.01,...
           'LineWidth',1,'BackgroundColor','k','Color','w','Units','normalized');