%Plot simulations with PI based structure

clc
clear all
close all

num=1; %case
name=strcat('PI',num2str(num));

load(name,'-mat')
IAE
IAE_q
Linewidth=1.3;

figure(1);

subplot(3,1,1)
plot(q_in.time,q_in.signals.values,'LineWidth',Linewidth)
title('Disturbance')
ylim([-0.1 1.1]); grid on; grid minor
ylabel('Inflow [m^3/s]')
hold off

subplot(3,1,2)
plot(h.time,h.signals.values,'k','LineWidth',Linewidth)
title('Proposed PI-based controller')
hold on
plot(tim,hmin,'--','Color',[255/255 165/255 0/255])
plot(tim,hmax,'--','Color',[255/255 165/255 0/255])
plot(tim,hminmin,'--r')
plot(tim,hmaxmax,'--r')
plot(tim,hsp,'--','Color',[0 165/255 115/255])
hold off
ylim([-0.1 1.1]); grid on; grid minor; ylabel('Level [m]')


subplot(3,1,3)
plot(q_outmax.time,q_outmax.signals.values,'r','LineWidth',Linewidth)  %,'Color',[105/255 56/255 27/255])
hold on;
plot(q_outmid.time,q_outmid.signals.values,'Color', [50/255 205/255 50/255],'LineWidth',2) 
plot(q_outmin.time,q_outmin.signals.values,'Color',[255/255 165/255 0/255],'LineWidth',Linewidth)
plot(q_out.time,q_out.signals.values,':k','LineWidth',1.5)
legend('q_{max,out}','q_{mid,out}','q_{min,out}','q_{out}','Location','southeast')
ylim([-0.1 1.1]); grid on; grid minor
%xlabel('time [s]');
ylabel('Outflow [m^3/s]');


fig = figure (1);
fig.PaperUnits = 'inches';
fig.PaperPosition = [0 0 8 7.5];
namefile=strcat('figures/PI',num2str(num));
saveas (figure (1), namefile,'eps2c'); 
