%%% Code for testing Plotting functions in Matlab
%%%
%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% XY Plotting Options

t = [0:0.1:2*pi];
x=10*sin(t);
y1=1*cos(t);
y2=3*cos(t);
y3=5*cos(t);
y4=7*cos(t);
y5=9*cos(t);

plot(t,x)

grid                    % Turns on Grid
axis([0 2*pi -15 15])   % Sets Axis Range ([xmin xmax ymin ymax])
xlabel('Abscissa is the Independant Variable');
ylabel('Ordinate is the Dependant Variable');
title('This is an Example Plot Title');

hold on                 % This keeps the plot in position so other can plot on it

plot (t,y1, '.b')       % data markers and colors can be added to a plot
plot (t,y2, '*c')       % remember that data markers only plot the specifi points
plot (t,y3, 'gx')       % so you need a lot of them to see the plot

plot (t,y4, 'm-')       % line types can also be used
plot (t,y5, 'r:')       % the default fit is "linear", change t to see the impact

legend('legend goes here')


hold off                % This makes it so that the next plot will overwrite the figure

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% XY Sub Plots

figure(2)               % This creates a new figure window called "Figure 2"
subplot(2,2,1)          % subplot creates an mxn plot window with syntax (m,n,p)
                        % m = the number of rows
                        % n = the number of columns
                        % p = directs the subsequent plot command where to
                        % plot
plot (t,y1, 'oy'), axis([0 2*pi -15 15]), grid

%%% plot to 2
subplot(2,2,2)
plot (t,y2, '+k'), axis([0 2*pi -15 15]), grid

subplot(2,2,3)
plot (t,y3, 'sb'), axis([0 2*pi -15 15]), grid

subplot(2,2,4)
plot (t,y4, 'db'), axis([0 2*pi -15 15]), grid

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Polar

figure(3)               % This creates a new figure window called "Figure 3"
                        % A polar plot graphs (theta vs. r) where 1 theta
                        % is 2pi

theta = [0:0.01:4*pi];
r = 2*theta
polar(theta,r), title('Spiral')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 3D Line Plots (plot3)

figure(4)               % This creates a new figure window called "Figure 4"
                        % A polar plot graphs (x vs. y. vs. z)
                        
s= [0:pi/50:10*pi];
plot3(exp(-0.05*s).*sin(s),  exp(-0.05*s).*cos(s),  s)
xlabel('x')
ylabel('y')
zlabel('z')
grid
                        


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% MESH Plots (mesh)

figure(5)
[X,Y] = meshgrid(-5:0.5:5);
Z = (X-2).^2+2*X.*Y+Y.^2;
mesh(X,Y,Z),xlabel('x'),ylabel('y'),zlabel('z')
                        
                        
                        
                        
                        
                        

