%plot results for CSTR disturbance 2 no outer
% Callum Kingstree

clc;close all;clear

set(0,'DefaultTextFontName','Times',...
     'DefaultTextFontSize',14,...
     'DefaultAxesFontName','Times',...
     'DefaultAxesFontSize',14,...
     'DefaultLineLineWidth',4,...
     'DefaultLineMarkerSize',7.75,...
     'DefaultStairLineWidth',2)

filename = {'NO_Chain_d2','NO_Gen_d2'...
    'NO_DL_d2','NO_Fitted_d2','OL_d2'};
linetype = {':','--','-.','-.',':',':'};  % string, can use diferent line type for each simulation
linewidth = [4, 3.5, 1.5, 2.5,2,2];

hotpink  = [0.8945    0.4102    0.5898];
peach    = [243/255 146/255 75/255];
coral  = [102/255 214/255 174/255];
lilac = [136/255 122/255 183/255];
purple = [59/255 40/255 96/255];
blue=[0 102/255 204/255];
linecol  = [peach;hotpink; coral; lilac; blue; purple];

for i =1:length(filename) % plot all saved results
     load(filename{i})    % load variable to workspace     
  
   
     subplot(121)
     plot(t,c_A,'Color',linecol(i,:),'LineStyle',linetype{i},...
         'LineWidth',linewidth(i))
       set(gca,'TickLabelInterpreter','latex')
     xlim([0 50])
     hold on    
     ylabel('Concentration [kmol m\textsuperscript{-3}]','Interpreter','latex')
     xlabel('Time [min]','Interpreter','latex')
     
end



for i = 1:4
    load(filename{i})
    
     
     subplot(122)
     plot(t,Q,'Color',linecol(i,:),'LineStyle',linetype{i},...
         'LineWidth',linewidth(i))
       set(gca,'TickLabelInterpreter','latex')
     hold on
     xlim([0 50])
    
     ylabel('Heat Added [kJ min\textsuperscript{-1}]','Interpreter','latex')
     xlabel('Time [min]','Interpreter','latex')
     
end
   
%legend('Chain','General','Second (DL)','Second (Fitted)','FB only')
%      figure(3)
%      %subplot(223)
%      plot(t,v,'Color',linecol(i,:),'LineStyle',linetype{i},...
%          'LineWidth',linewidth(i))
%      hold on     
%      xlim([0 500])
%      ylabel('Transformed input')
%      xlabel('Time [min]')
%     
%      figure(4)
%      %subplot(224)
%      plot(t,T,'Color',linecol(i,:),'LineStyle',linetype{i},...
%          'LineWidth',linewidth(i))
%      hold  on
%      xlim([0 500])
%      ylabel('Temperature')
%      xlabel('Time [min]')
%      

%Add setpoints 
subplot(121);plot(t,y_sp,'--','Color','black','LineWidth',2);

lgd =legend('Chain','General','Alt (DL)',...
    'Alt (Fitted)','O-L','Set-point','Interpreter','latex'); 
lgd.FontSize = 8;
x0=10;
y0=10;
width=900;
height=270;
set(gcf,'position',[x0,y0,width,height])