% Exa = 1;
switch Exa
case 1 % very basic
x = 0:0.5:7
y1 = sin(x)
plot(x,y1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 2 % two plots, labes, title
y2 = cos(x).*exp(-x/3);
plot(x,y1,'-*r',x,y2,'+b')
legend('sin(x)','cos(x)*exp(-x/3)')
title('two elementary graphs');
grid on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 3
clf % clear the current figure
x = -4:0.1:4;
y = (1+x.^2).*exp(3*x);
semilogy(x,y);
text(-3,2000,'Text in Graph');
title('logarithmic scale in vertical direction')
xlabel('Distance [m]'); ylabel('Temp [K]')
print('graph3.pdf','-dpdfwrite') % Octave only
print('graph3.eps','-depsc','-FTimes-Roman:20') % slightly different in Matlab
print('graph3.png','-S600,400') % different in Matlab
% to obtain a 4 by 3 inches picture with a resolution of 200dpi use
%set(gcf,'PaperUnits','inches','PaperPosition',[0 0 4 3])
%print('graph3.png','-dpng','-r200')
printFigureToPdf('graph3a.pdf',[4,3],'inches',[0.1 0.1 0.1 0.01])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 4
x = linspace(0,10);
figure(1); plot(x,sin(x))
set(gca(),'XTick',[0:pi/2:3*pi],...
'XTickLabel',{'0','\pi/2','\pi','3\pi/2','2\pi','5\pi/2','3\pi'})
set(gca(),'XGrid','on')
set(gca(),'YTick',[-0.5,0,0.4,1])
set(gca(),'YMinorGrid','on');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 5
x = linspace(-2*pi,2*pi,200);
clf
axis('normal');
axis(); % leave the scaling up to Octave
subplot(2,2,1) % create a 2x2 grid of plots, plot in the first
plot(x,sin(x));
subplot(2,2,2) % plot in the second
plot(x,cos(x));
subplot(2,2,3) % plot in the third
plot(x,sinh(x));
subplot(2,2,4) % plot in the fourth
plot(x,cosh(x));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 6
x = -5*pi:0.01:5*pi; y = sin(x);
figure(1); clf
hist(y,20)
axis([-1.3 1.3]); % Matlab can not choose the x-scaling only
figure(2);
[height,center] = hist(y,-1:0.1:1,1)
height = height/sum(height);
bar(center,height);
axis([-1.2 1.2]); % Matlab can not choose the x-scaling only
end%switch