%Plot process measurement and prediction

% aux=open('solOPT.mat');
% sol=aux.solOPT;
future=getGuess(housepred,initialStates,sol,tinit,horizon);


Trpred=future.Tr-273;
Tfpred=future.Tf-273;
co2pred=future.co2;
qhfpred=future.qhf;
qhrpred=future.qhr;
qairpred=future.qair;
costpred=future.J;
Topred=future.To-273;
pricepred=future.price;

timepred=future.t;
timenow=Timevec(end)/3600;
timepred=timepred/3600;
time=Timevec/3600;



yrange1=[288 301]-273;
yrange2=[288 273+31]-273;
yrange3=[0 0.2];

urange1=[0 5];
urange2=[0 1];
urange3=[0 0.006];
Linewidth=1.5;


color1=[102, 194, 165]/256;
color2=[252, 141, 98]/256;
color3=[141, 160, 203]/256;



figure(20)
subplot(311)
p1=plot(time,Uvec(:,1),timepred,qhfpred,'LineWidth',Linewidth)
set(p1(1),'color',color1)
set(p1(2),'color',color2)
set(gca,'FontSize',14)
ylabel('$Q_f$, kW','interpreter','latex')
ylim([0 5])
xlim([0 24])
subplot(312)
p1=plot(time,Uvec(:,2),timepred,qhrpred,'LineWidth',Linewidth)
set(p1(1),'color',color1)
set(p1(2),'color',color2)
set(gca,'FontSize',14)
ylabel('$Q_r$, kW','interpreter','latex')
ylim([0 .5])
xlim([0 24])
% axis tight
subplot(313)
p1=plot(time,Uvec(:,3),timepred,qairpred,'LineWidth',Linewidth)
set(p1(1),'color',color1)
set(p1(2),'color',color2)
set(gca,'FontSize',14)
xlabel('Time, h','interpreter','latex')
ylabel('$q_{in}$, Kg/s','interpreter','latex')
ylim(urange3)
xlim([0 24])
% axis tight

figure(10)
subplot(311)
plot(time,Yvec(:,2)-273,timepred,Trpred,'k-.',[0 simtime/3600],[17 17],'r',[timenow timenow],yrange1,'w','LineWidth',Linewidth)
set(gca,'FontSize',14)
% xlabel('Time, h','interpreter','latex')
ylabel('$T_r$, $^{\circ}C$','interpreter','latex')
% axis tight
ylim(yrange1)
xlim([0 24])

subplot(312)
plot(time,Yvec(:,1)-273,timepred,Tfpred,'k-.',[0 simtime/3600],[+30 +30],'r',[timenow timenow],yrange2,'w','LineWidth',Linewidth)
set(gca,'FontSize',14)
% xlabel('Time, h','interpreter','latex')
ylabel('$T_f$, $^{\circ}C$','interpreter','latex')
% axis tight
ylim(yrange2)
xlim([0 24])

 subplot(313)
 ylim(yrange3)
  plot(time,100*Yvec(:,4),[0 simtime/3600],100*[par.co2max par.co2max],'r','LineWidth',Linewidth)
%  plot(time,100*Yvec(:,4),'LineWidth',Linewidth)
  set(gca,'FontSize',14)
  xlabel('Time, h','interpreter','latex')
  ylabel('$y$, \%','interpreter','latex')
 % axis tight
 ylim([0 0.2])
 xlim([0 24])




figure(30)
subplot(312)
Topred=0*273+[-1.2 -1.1 -2.2 -1.7 -2.9 -3.6 -3.3 -4.2 -3.4 -1.9 -2.3 -3.5 -2.2 0.9 1.1 1.1 1.0 1.4 1.2 1.9 2.9 3.5 3.1 3.3];
hours=linspace(0,24,24);
plot(hours,Topred,'k-.',time,Yvec(:,6)-273,'b','LineWidth',Linewidth)
set(gca,'FontSize',14)
ylabel('$T_o$, $^{\circ}C$','interpreter','latex')
ylim([-5 +5])
xlim([0 24])
subplot(311)
plot(time,Yvec(:,7),timepred,pricepred,'k-.','LineWidth',Linewidth)
set(gca,'FontSize',14)
ylabel('Price, \$/kWh','interpreter','latex')

xlim([0 24])
subplot(313)
plot(time,Yvec(:,5),timepred,costpred,'k-.','LineWidth',Linewidth)
set(gca,'FontSize',14)
ylabel('Cost, \$','interpreter','latex')
xlabel('Time, h','interpreter','latex')
 tilefigs


xlim([0 24])