%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Demonstrates basic use of Matlab plot function for making 
% x-y plots.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Clear the figure window.
clf

% Generate vector of x coordinates.
x = linspace(-2*pi,2*pi,1000);

% Evaluate and store two different functions at x values.
% Note use of element-wise multiplication operator.

y1 = cos(3*x) .* sin(x);
y2 = sin(2*x) .* cos(x/3);

% Plot the two functions using a red line and small blue circles, 
% respectively.
plot(x, y1, 'r', x, y2, 'ob');

% Give the plot a title, axes label and legend (these commands
% need to come AFTER the plot command).
title('Plot of two of my favorite functions');
xlabel('x');
ylabel('f(x)');
legend('cos(3x) sin(x)', 'sin(2x) cos(x/3)', 'location', 'best');

% Save the plot as a JPEG image.
print('tplot.jpg', '-djpeg');
