%
% plot05.m
%
% Plot n sine curves on the same plot. Use the command hold all to prevent
% the plots from overwriting each other. 
%
% Matlab-Monkey.com
% 12/30/2014

% tidy-up your workspace
clc         % clear command window
clear       % clear all variables
close all   % close all graphics windows

period = 10;                  % define the period of the signal
t = linspace(0,period,200);   % 200 data points evenly spaced over 1 period
   
% create a sine wave and add Gaussian noise to it
% plot as blue data points
y2 = sin(2*pi/period*t) + 0.5*randn(1,length(t));   
plot(t,y2,'bo', 'MarkerSize',2, 'MarkerFaceColor', 'b');

% prevent future plots from overwriting current plot 
hold all 

% create a sine wave with no noise and plot as red curve
y = sin(2*pi/period*t);             
plot(t,y,'r-')    % blue line 
 
% label axes
xlabel('t')          
ylabel('y(t)')
axis([0 period -4 4]);
legend('sine + noise','sine');



h = 4;                                  % height of plot in inches
w = 6;                                  % width of plot in inches
set(gcf, 'PaperSize', [w h]);           % set size of PDF page
set(gcf, 'PaperPosition', [0 0 w h]);   % put plot in lower-left corner
print ('-dpdf','plot07.pdf');           % save plot as pdf file
print ('-dpng','html/plot07.png');           % save plot as pdf file

