%% Plotting Experimental MPC Results

clc
close all

%% 20.05

T = readtable('ExpDataMPC/Data_20.05.xlsx');
xSP = 28;

%% Reading data

Zo = T{:,2};
betaIn = T{:,3};
timeElapsed = T{:,4};
t = T{:,6};
betaU = T{:,9};
Qin = T{:,8};
% Qu = T{:,9};
betaUpred = T{:,10};

%% Plot

set(groot, 'defaultTextInterpreter','latex');
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');

figure('visible', 'on')
subplot(3,1,1)
stairs(t,Zo, 'b')
ylabel('$Z_O$ [\%]')
xlim([1678 2262])
% title('MV - Overflow Valve Opening')

xL = 22;
subplot(3,1,2)
plot(t, betaUpred, 'b')
hold on
plot(t, betaU, 'g')
hold on
ylim([10 35])
yline(xSP, '--r')
hold on
yline(xL, '--r')
ylabel('$\beta_{U,o}$ [ppm]')
legend('Predicted', 'Measured', 'location', 'southeast', 'fontsize', 6)
xlim([1678 2262])
% title('CV - Underflow Oil Concentration (Prediction)')

subplot(3,1,3)
plot(t,Qin, 'b')
% title('DV1 - Flowrate Inlet')
xlim([1678 2262])
ylim([3.80 4.25])
ylabel('$Q_{in}$ [m$^3$/h]')
xlabel('$t$ [s]')

% subplot(4,1,4)
% plot(t,betaIn)
% ylabel('$\beta_{in}$ [ppm]')
% xlabel('$t$ [s]')
% xlim([1678 2262])
% % title('DV2 - Oil Concentration Inlet')

saveas(gcf,[pwd '/Figures/MPC_Flowrate_20_05'],'epsc')
