%
% plot05.m
%
% Plot three curves on the same plot. Include a legend.
%
% Matlab-Monkey.com
% 12/30/2014

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

x = linspace(0,2*pi,100);   % 100 data points evenly spaced from 0 to 2*pi
y = sin(x);                 % first curve has a phase = 0
y2 = 2 * sin(x - pi/6);     % second curve has a phase = pi/6
y3 = 3 * sin(x - pi/3);     % third curve has a phase = pi/3

plot(x,y, x,y2, x,y3)       % plot all three curves

xlabel('x')
ylabel('Wave height')
title('Three Sine Waves', 'FontSize',14)
axis([0 2*pi -4 4])
legend('sin(x)', '2 sin(x-\pi/6)', '3 sin(x-\pi/3')

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','plot05.pdf');           % save plot as pdf file
print ('-dpng','html/plot05.png');           % save plot as pdf file

