next up previous contents
Next: 3D plots Up: Advanced Graphics Previous: Advanced Graphics

Putting several graphs in one window

The subplot command creates several plots in a single window. To be precise, subplot(m,n,i) creates mn plots, arranged in an array with m rows and n columns. It also sets the next plot command to go to the ith coordinate system (counting across the rows). Here is an example (see Figure 7):

>> t = (0:.1:2*pi)';
>> subplot(2,2,1)
>> plot(t,sin(t))
>> subplot(2,2,2)
>> plot(t,cos(t))
>> subplot(2,2,3)
>> plot(t,exp(t))
>> subplot(2,2,4)
>> plot(t,1./(1+t.^2))

   figure253
Figure 7: Using the subplot command



Mark S. Gockenbach
Wed Sep 8 10:44:13 EDT 1999