% Script for plotting the loss with the null space method
% resulting from simulations in Simulink

load VnsSim                                         % Loading the cost values 
load VnsSimOpt                                      % Loading the optimal cost values
loss_ns=((VnsSim-VnsSimOpt)./VnsSimOpt)*100;        % Calculating the loss
loss_ns=abs(loss_ns);                               % Making the values positive
F0=368:11.5:552;                                    % F0-values for the x-axis

% Making the plot of the loss versus F0
figure (1)
xx=F0;
yy=spline(F0,loss_ns,xx);
plot(xx,yy,'b','LineWidth',2.5)
xlim([400 550])
ylim([0 5])
set(gca,'XTick',400:30:550);
set(gca,'YTick',0:1:5);
xlabel('F_0 [kmol/h]','FontSize',12,'FontWeight','bold')
ylabel('Loss [%]','FontSize',12,'FontWeight','bold')
title('Null Space Method','FontSize',12,'FontWeight','bold')