function intrompqpv2
% plot two quadratic functions
%
% M. Herceg, Automatic Control Laboratory, ETH Zurich 2014

close all
%% printing parameters
label_font_size = 14;
tick_font_size = 10;
line_width = 0.8;
axeswidth=0.2;
% create new folder for storing figures
mkdir('figures');
figure_name = ['.',filesep,'figures',filesep,'intrompqpv2'];

%% core code
x=[-2:0.01:2];
x1=[-2:0.01:-1/3];
x2=[-1/3:0.01:2];
z1=3*x1+1;
%J1=5/2*x1.^2+3*x1+1/2;
J1=9/2*x1.^2+3*x1+1/2;
z2=0*x2;
J2=0*x2.^2;
vx=0*x-1/3;

% plot figures
figure 
hold on
grid on
plot([x1 x2],[z1 z2],'k-','LineWidth',line_width)
plot([x1 x2],[J1 J2],'k-.','LineWidth',line_width)
plot(vx,x,'k--','LineWidth',line_width)
axis([-2,2,-2,2]);
% custom axis labels & font size
hx = xlabel('$x$');
set(hx, 'FontSize', label_font_size);
set(gca,'LineWidth',axeswidth)


%% save book figures
% font size of tick labels
set(gca, 'FontSize', tick_font_size);
xl = transpose(-2:1:2);
yl = transpose(-2:1:2);
set(gca,'XTick',xl);
set(gca,'YTick',xl);
set(gca,'XTickLabel',num2str(xl));
set(gca,'XTickLabel',num2str(yl));


ht1=text(-1.5,-0.8,'${z}^{*}(x)$');
ht2=text(-1.8,1.7,'${J}^{*}(x)$');
set(ht1, 'FontSize', label_font_size);
set(ht2, 'FontSize', label_font_size);

% generate FIG file
disp('Hit any key to print the figure and continue.');
pause
saveas(gcf, [figure_name '_matlab'], 'fig');

% print using laprint
title('')
laprint(gcf, [figure_name '_tex'],'scalefonts','off');


end