% Script to plot results for pH
% dist in q1
% Callum Kingstree
% Dec 2020

clc; clear all; close all

set(0,'DefaultTextFontName','Times',...
     'DefaultTextFontSize',20,...
     'DefaultAxesFontName','Times',...
     'DefaultAxesFontSize',20,...
     'DefaultLineLineWidth',4,...
     'DefaultLineMarkerSize',7.75,...
     'DefaultStairLineWidth',2)
 
filename = {'cH_controller_dist_q1.mat','cHsp_controller_dist_q1.mat',...
'cH_no_controller_dist_q1.mat','cHsp_no_controller_dist_q1.mat'};
linetype = {':','--','-.','-.'};  
linewidth = [4, 3.5, 3, 2.5];

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];
orange = [204/255 68/255 10/255];
blue = [0 6/255 102/255];
red = [255/255 89/255 89/255];
lighterblue = [0/255 68/255 178/255];
darkpink = [229/255 57/255 143/255];
minty = [8/255 165/255 105/255];
purple = [59/255 40/255 96/255];
black = [38/255 38/255 38/255];
grey = [120/255 120/255 120/255];
%linecol  = [peach;hotpink; coral; lilac];
linecol  = [peach;hotpink; coral; lilac; blue; purple];

for i =1:length(filename) % plot all saved results
     load(filename{i})
      subplot(121)   
     plot(t,pH,'Color',linecol(i,:),'LineWidth',linewidth(i),'LineStyle',linetype{i})
     set(gca,'TickLabelInterpreter','latex')
     ylim([4 11])
     xlim([0 10000])
     ylabel('pH','Interpreter','latex')
     xlabel('Time [s]','Interpreter','latex')
     hold on
end

plot(t,ysp,'Color',black,'LineWidth',1,'LineStyle','--')

lgd = legend ('$c = f([H^+])$','$c = f([H^+_{sp}])$', ...
    '$c = f([H^+]) \;$ (no controller)','$c = f([H^+_{sp}]) \;$ (no controller)','Set-point','Interpreter','latex');
lgd.FontSize = 12.5;

for i =1:length(filename) % plot all saved results
     load(filename{i})
     
    subplot(122)
     plot(t,q_3_GLT,'Color',linecol(i,:),'LineWidth',linewidth(i),'LineStyle',linetype{i})
     set(gca,'TickLabelInterpreter','latex')
     xlim([0 10000])
     ylim([10 20])
     ylabel('Flow of Stream 3   [ml s\textsuperscript{-1}]','Interpreter','latex')
     xlabel('Time [s]','Interpreter','latex')
     hold on
end

x0=10;
y0=10;
width=900*1.5;
height=270*1.5;
set(gcf,'position',[x0,y0,width,height])

%sgtitle('Disturbance of $q_1$ (unmeasured)','Interpreter','latex')