To help those of you who could not start Matlab on Monday, and to help
the rest in reviewing the new material, I want to give you a worksheet
that summarizes all the new plotting commands that we learned; it also
includes two new commands, "legend" and "set(gca)":
subplot(3,1,1);
x=0.5:0.01:10;
y=x./(x.^2+1);
y2=1./x;
plot(x,y,'b',x,y2,'r');
title('Comparison of functions x/(x^2+1) and 1/x');
xlabel('x'); ylabel('x/(x^2+1), 1/x');
legend('x/(x^2+1)','1/x');
subplot(3,1,2);
plot(x,y,'b',x,y2,'r');
axis([5 10 0.1 0.2]);
title('Same, but for x on the interval [5, 10]');
xlabel('x'); ylabel('x/(x^2+1), 1/x');
legend('x/(x^2+1)','1/x');
subplot(3,1,3);
plot(log(x),log(y));
axis([log(5) log(10) log(0.1) log(0.2)]);
title('Log-Log plot of f(x)=x/(x^2+1); note that the slope equals -1');
xlabel('x'); ylabel('x/(x^2+1)');
set(gca,'XMinorTick','On');
set(gca,'YMinorTick','On');
set(gca,'YTick',[-2.3 -2.2 -2.1 -2.0 -1.9 -1.8 -1.7 -1.6]);
Please practice by entering each command one by one, and observing the
result. Again, you can lookup info on any of the commands you didn't
understand by using the "help" command. The last command,
"set(gca,...)", can be used to set a variety of plot details. Its
general format is set(gca,'option_name','value'). To see the list of
different options that can be changed, type "set(gca)". The keyword
"gca" means "get current axis", and is a structure (an object)
containing all the data of the current plot.