% To load into Matlab:  just type the name of this file, without the .m
% extension.

clf;

xmin= 0;
xmax= 4;
ymin=-20;
ymax= 20;
xtick=1;
ytick=10;

%% ----------------------------------------------------------------
hold on;

x=[0:0.01:1]; y=    20*x; plot(x,y);
x=[1:0.01:2]; y= 40-20*x; plot(x,y);
x=[2:0.01:3]; y= 20-10*x; plot(x,y);
x=[3:0.01:4]; y=-40+10*x; plot(x,y);

%% ----------------------------------------------------------------
axis([xmin xmax ymin ymax]);
h1=line([xmin xmax], [0 0]);
set(h1, 'LineStyle', '--');
h2=line([0 0], [ymin ymax]);
set(h2, 'LineStyle', '--');
xlabel('x');
ylabel('g''(x)');

set(gca, 'XTick', [xmin:xtick:xmax])
set(gca, 'YTick', [ymin:ytick:ymax])

set(gca, 'XGrid', 'on')
set(gca, 'YGrid', 'on')
%set(gca, 'XMinorGrid', 'on')
%set(gca, 'YMinorGrid', 'on')

set(gcf, 'PaperPositionMode', 'Manual');
set(gcf, 'PaperPosition', [0 0 4.0 2.0])
print -depsc e4_g
