% Script File: sineANDcosinePLOT.m % % plots sine and cosine together % in various ways % clc,clear x = linspace(0,pi,200); y1 = sin(2*pi*x); y2 = cos(2*pi*x); plot(x,y1,x,y2); % plot y1 and y2 as a fn. of x pause % MATLAB waits until % a key is pressed in the command window. plot(x,y1); % plot y1 as a function of x hold on; % want to put another plot into the same figure plot (x,y2,'--'); % plot y2 as a function of x % along with y1 in the same figure hold off % figure is finished pause % Two different plots in the same figure subplot(2,1,1); % 2 rows of plots in the figure % 1 column of plot in the figure % we are now drawing the first (top) plot plot(x,y1); title('The function y1=sin(2*pi*x)') xlabel('x (in radians)') ylabel('y1') subplot(2,1,2); % 2 rows of plots in the figure % 1 column of plot in the figure % we are now drawing the second (bottom) plot plot(x,y2); title('The function y2=cos(2*pi*x)') xlabel('x (in radians)') ylabel('y2')