Different Plot Example

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DiffPlotEx.m 
% Written by Ebenezer P Gnanamanickam 
% Dec 2006.
% DISCLAIMER - I do not claim to be an expert on MATLAB but what little I
% have learned during the course of grad school here at Purdue University
% I want to share. If it's useful GREAT if not sorry.
% GENERAL ADVICE FOR HELP ON MATLAB - if you need help in order of usefulness 
% 1) Google it - this will sort 90% of your problems . If you are wondering
% if MATLAB can do something chances are it probably can. So google!!!!
% 2) Talk to a graduate student like me who has been around for years and
% is now considered part of the furniture in the department
% 3) If you are at Purdue go talk to Dr. Marc Williams - He is the resident
% expert on MATLAB and coding in general - NOTE thought this is a last
% resort as he is a busy man. 
% If Dr. Williams cannot help you then chances are that it cannot be done.
% So give up. Unless you are a glutton for punishment ... like me!!!!
% I hope this helps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% 
% This script plots the run time for a simple problem which was solved
% using for loops, vectorized operations, for loop with variable 
% declaration and vectorized operation with variable decalaration.
% The object is to demonstrate different plot styles
% Fig 1. Standard line plot
% Fig 2. Simple log log line plot
% Fig 3. A semi log plot with symbols
% fig 4. Semi log plot with zoomed in view with different line styles
% Things to be noted are how the syntaxes work, how to zoom in etc etc.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; % clears the command window
clear all; % clears all the variables
close all; % close all exsisting windows

a=[100	0.21	0.21	0.21	0.21
1000	0.21	0.21	0.21	0.21
5000	0.33	0.21	0.21	0.21
10000	0.861	0.21	0.21	0.21
20000	2.994	0.21	0.23	0.21
40000	11.337	0.21	0.24	0.21
60000	28.801	0.24	0.26	0.24];

n=a(:,1);
m1=a(:,2);
m2=a(:,3);
m3=a(:,4);
m4=a(:,5);

figure
plot(n,m1,'r',n,m2,'b',n,m3,'k',n,m4,'c');
xlabel('number of points')
ylabel('machine time in seconds');
title('Simple line plots')
legend('for loop operations','vectorized operations',...
    'for loop operations with variable decleration',...
    'vectorized operations with variable deceleration',2);
grid

figure
loglog(n,m1,'-r',n,m2,'-b',n,m3,'-k',n,m4,'-c');
xlabel('number of points')
ylabel('machine time in seconds');
title('Simple log log line plot')
legend('for loop operations','vectorized operations',...
    'for loop operations with variable decleration',...
    'vectorized operations with variable deceleration',2);
grid

figure
semilogy(n,m1,'*r',n,m2,'.b',n,m3,'dk',n,m4,'oc');
xlabel('number of points')
ylabel('machine time in seconds');
title('Semi log plots with symbols');
legend('for loop operations','vectorized operations',...
    'for loop operations with variable decleration',...
    'vectorized operations with variable deceleration',2);
grid

figure
loglog(n,m1,'-r',n,m2,':b',n,m3,'-.k',n,m4,'--c');
xlabel('number of points')
ylabel('machine time in seconds');
title('Semi log plot with zoomed in view with different line styles');
legend('for loop operations','vectorized operations',...
    'for loop operations with variable decleration',...
    'vectorized operations with variable deceleration',2);
grid
axis([0 80000 0 0.4])