MATLAB/Cookbook/subplot

clc,clear all,

%this gives you the range of numbers x = [-10:1:10];

%This will plug in the x from -10 to 10 in the a's a1 = x;     a2 = x.^2;    a3 = x.^3; a4 = x.^4;  a5 = x.^5;    a6 = x.^6;

%plots a1 = x %this makes a subplot at 3x2 and puts in the column 1 and row 1 subplot(3,2,1) %plots the (y,x,'Color') plot(x,a1,'b') xlabel('X') ylabel('Y') title('X')

%plots X squared subplot(3,2,2) plot(x,a2,'g') xlabel('X') ylabel('Y') title('X squared')

%plots X cubed subplot(3,2,3) plot(x,a3,'r') xlabel('X') ylabel('Y') title('X cubed')

%plots X to the fourth subplot(3,2,4) plot(x,a4,'g') xlabel('X') ylabel('Y') title('X to the fourth')

%plots X to the fifth subplot(3,2,5) plot(x,a5,'k') xlabel('X') ylabel('Y') title('X to the fifth')

%plot X to the sixth

subplot(3,2,6) plot(x,a6,'b') xlabel('X') ylabel('Y') title('X to the sixth')