%
% plot08.m
%
% Plot sin(x)
%
% Programming Concepts:  Simple line plot, set plot limits
%
% 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,50*pi,1000);  % define 1000 x values from 0 to 50 pi

% two sine waves beating near 1:1 "resonance"
y = sin(x)+sin(1.1*x);      
subplot(3,1,1);             % three horizontal panels, plot top one first
plot(x,y)
axis([0 50*pi -2.2 2.2])
ylabel('y')
title('1:1 Beats    sin(x) + sin(1.1*x)', 'FontSize',12)   

% two sine waves beating near 2:1 "resonance"
y = sin(x)+sin(2.1*x);
subplot(3,1,2);             % now make a plot in the middle panel
plot(x,y)
axis([0 50*pi -2.2 2.2])
ylabel('y')
title('2:1 Beats    sin(x) + sin(2.1*x)', 'FontSize',12)

% two sine waves beating near 3:1 "resonance"
y = sin(x)+sin(3.1*x);
subplot(3,1,3);             % this plot will be in the bottom panel
plot(x,y)
axis([0 50*pi -2.2 2.2])
title('3:1 Beats    sin(x) + sin(3.1*x)', 'FontSize',12)
ylabel('y')
xlabel('x')                 % label the x axis only on the bottom plot
                            % the x label bumps into the title on the upper
                            % plots


w = 8;      % plot width in inches
h = 5;      % plot height in inches
set(gcf, 'PaperSize', [w h]);  
set(gcf, 'PaperPosition', [0 0 w h]);  
print ('-dpdf','plot08.pdf');
print ('-dpng','html/plot08.png');