% Appendix A: MATLAB Basics, Section A.4
%
%    MATLAB graphics described in Section A.4  
%    includes Figures A.18 - A.20.  After each subtopic, a 
%    pause is inserted to allow you to inspect the output.  Hit 
%    the space bar (or any other key) to continue to the next 
%    subtopic.
%
clear
format
hold off
clf
% -------------- Figure A.18
x=[0:0.1:1]';
y=x.*sin(x);
plot(x,y)
title('Figure A.18: Plot of x sin(x) vs x')
xlabel('x')
ylabel('y')
grid on
pause
%
% -------------- Figure A.19
x=[0:0.1:1]';
y1=x.*sin(x); y2=sin(x);
plot(x,y1,'--',x,y2,'-.')
text(0.1,0.85,'y_1 = x sin(x) - - -')
text(0.1,0.80,'y_2 = sin(x) .\_.\_ ')
xlabel('x')
ylabel('y_1 and y_2')
title('Figure A.19')
grid
pause 
%
% -------------- Figure A.20
dx=[0:0.1:1]';
y1=x.*sin(x); y2=sin(x);
subplot(2,2,1),plot(x,y1,'--',x,y2,'-.')
title('Figure A.20a: subplot(2,2,1)')
subplot(2,2,2),plot(x,y1,'--',x,y2,'-.')
title('Figure A.20b: subplot(2,2,2)')
subplot(2,2,3),plot(x,y1,'--',x,y2,'-.')
title('Figure A.20c: subplot(2,2,3)')
subplot(2,2,4),plot(x,y1,'--',x,y2,'-.')
title('Figure A.20d: subplot(2,2,4)')