function ex_order
% example of multivalued pwa map
%
% M. Herceg, Automatic Control Laboratory, ETH Zurich, 2012, 2014


close all

%% printing parameters
label_font_size = 14;
tick_font_size = 10;
line_width = 0.8;
axeswidth=0.2;
% create folder for storing figures
mkdir('figures');
figure_name1 = ['.',filesep,'figures',filesep,'fig_ex_order_1'];
figure_name2 = ['.',filesep,'figures',filesep,'fig_ex_order_2'];
figure_name3 = ['.',filesep,'figures',filesep,'fig_ex_order_3'];


%% core code
fig1=figure;
plot(-2:1,zeros(4,1),'k','linewidth',line_width)
grid on
hold on
plot(0:2,[0 1 2],'k','linewidth',line_width);
hold off
axis([-2 2 -1 2])
title('')
hx1 = xlabel('$x$');
hy1 = ylabel('$\zeta(x)$');
ht1 = text(-0.5,1.25,'$F_1x+G_1$');
ht2 = text(-1.5,0.25,'$F_2x+G_2$');
set(gca,'YTickLabel',{''})
set(gca,'XTickLabel',{''})
set(gca,'LineWidth',axeswidth)
set(gca, 'FontSize', tick_font_size);
set(hx1, 'FontSize', label_font_size);
set(hy1, 'FontSize', label_font_size);
set(ht1, 'FontSize', label_font_size);
set(ht2, 'FontSize', label_font_size);


fig2=figure;
plot(-2:1,zeros(4,1),'k','linewidth',line_width)
grid on
hold on
plot(1:2,[1 2],'k','linewidth',line_width);
hold off
axis([-2 2 -1 2])
%title('')
hx2 = xlabel('$x$');
ht3 = title('$\zeta_{12}(x)=\left \downarrow\ba{l} F_1x+G_1 ~ \text{if} ~ x\in \RR_1 \\ F_2x+G_2 ~ \text{if} ~ x\in \RR_2 \ea \right.$');
set(gca,'YTickLabel',{''})
set(gca,'XTickLabel',{''})
set(gca,'LineWidth',axeswidth)
set(gca, 'FontSize', tick_font_size);
set(hx2, 'FontSize', label_font_size);
set(ht3, 'FontSize', label_font_size);


fig3=figure;
plot(-2:0,zeros(3,1),'k','linewidth',line_width)
grid on
hold on
plot(0:2,0:2,'k','linewidth',line_width);
hold off
axis([-2 2 -1 2])
%title('')
hx3 = xlabel('$x$');
ht4 = title('$\zeta_{21}(x)=\left \downarrow\ba{l} F_2x+G_2 ~ \text{if} ~ x\in \RR_2 \\ F_1x+G_1 ~ \text{if} ~ x\in \RR_1 \ea \right.$');
set(gca,'YTickLabel',{''})
set(gca,'XTickLabel',{''})
set(gca,'LineWidth',axeswidth)
set(gca, 'FontSize', tick_font_size);
set(hx3, 'FontSize', label_font_size);
set(ht4, 'FontSize', label_font_size);


%% save book figures
saveas(fig1, [figure_name1,'_matlab'], 'fig');

laprint(fig1, [figure_name1,'_tex'],'scalefonts','off');

saveas(fig2, [figure_name2,'_matlab'], 'fig');

laprint(fig2, [figure_name2,'_tex'],'scalefonts','off');

saveas(fig3, [figure_name3,'_matlab'], 'fig');

laprint(fig3, [figure_name3,'_tex'],'scalefonts','off');

end