40 C H A P T E R 0: From the Ground Up!
FIGURE 0.17
Results of using the function ff(.)
(notice the difference in scale in the
x axis).
0 20 40 60 80 100
0
0.5
1
1.5
2
2.5
x
y=
ff(
x)
0 0.5 1 1.5 2 2.5
0
0.1
0.2
0.3
0.4
0.5
0.6
x
y=
ff(
x)
In thesubplotfunction the first two numbers indicate the number of rows and the number of columns,
and the last digit refers to the order of the graph that is, 1, 2, 3, and 4 (see Figure 0.18).
There is also a way to control the values in the axis, by using the function (you guessed!)axis. This
function is especially useful after we have a graph and want to improve its looks. For instance, suppose
that the professor would like the above graphs to have the same scales in the y-axis (picky professor).
You notice that there are two scales in the y-axis, one 0-0.8 and another 0-3. To have both with the
same scale, we choose the one 0-3, and modify the above code to the following
subplot(221)
plot(x, y)
axis([0 100 0 3])
subplot(222)
plot(x, z)
axis([0 100 0 3])
subplot(223)
stem(x, y)