%=========================================================================
% Decription: this is an example for how to develop a matlab script to plot
% a function
% 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;
%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)}
plot(x,y,'r');
%add the labels and title
title('Demonstration plot for CogSci 109 - plotting a function')
xlabel('x - time (seconds)')
ylabel('y - depth of ocean(mm)')