% Script to plot results for pH
% cascaded
% 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 = {'general.mat','Alt_Wa4.mat','Alt_Wb4.mat','chain.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')
     xlim([0 7000])
     ylabel('pH','Interpreter','latex')
     xlabel('Time [s]','Interpreter','latex')
     hold on
end

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

lgd = legend ('General','Alt ($W_{a4}$)', 'Alt ($W_{b4}$)','Chain','Set-point','Interpreter','latex');

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 7000])
     ylim([5 20])
     ylabel('Flow of Stream 3   [ml s\textsuperscript{-1}]','Interpreter','latex')
     xlabel('Time [s]','Interpreter','latex')
     hold on
end


