%=========================================================================
% Decription: this is an example for how to develop a matlab script to plot 
%             more than one function in a single figure window, different
%             plots
% Author : C. Alex Simpkins
% Date : Oct 1, 2006
%
%=========================================================================

%remember this is a comment, it is not executed by your computer, it just
%tells us information about the code...start the line with a percent sign
%to make the rest of the line a comment

%define the domain which we will plot the function over 
%this is the same as stating mathematically 0<=x<=10
x=0:0.1:10;

%define the function to plot.  If x is the input, this is the output
y = 5*x.^2 - 3.*(x-5).^3;
z = y.*sin((x-5)*pi);

%now create a figure to plot in (if you don't include this and it is the
%only plot, matlab will create the figure for you.  This is more useful for
%when you want to create more than one plot window.  You can also specify a
%number, ie figure(1).  Then later if you want to go back to that window
%and add a plot to it, you can make the figure(1) statement before the plot
%command
figure;

%plot the values at each point contained in the vectors x and y (ie
%{x(1),y(1)}, {x(2),y(2)}...,{x(n),y(n)} 
subplot(2,1,1), plot(x,y,'r');

%now add the labels and title...
title('Demonstration plot for CogSci 109 - plotting a function')
xlabel('x - time (seconds)')
ylabel('y - depth of ocean(mm)')


%now plot the second function...
subplot(2,1,2), plot(x,z,'b');

%add the labels and a second title (notice that for each plot you have a 
%unique title and set of axis labels)
title('Another function- look at me, look at me!!!')
xlabel('x - time (seconds)')
ylabel('z - depth of ocean in evening(mm)')


