\documentclass[12pt]{article}

\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{listings}
\usepackage[colorlinks=true,linkcolor=black,urlcolor=blue]{hyperref} 
\usepackage{dirtree}
\usepackage{courier}


 \lstset{
	 language=Matlab,
         basicstyle=\footnotesize\ttfamily, % Standardschrift
         %numbers=left,               % Ort der Zeilennummern
         numberstyle=\tiny,          % Stil der Zeilennummern
         %stepnumber=2,               % Abstand zwischen den Zeilennummern
         numbersep=5pt,              % Abstand der Nummern zum Text
         tabsize=2,                  % Groesse von Tabs
         extendedchars=true,         %
         breaklines=true,            % Zeilen werden Umgebrochen
         keywordstyle=\color{black},
    		frame=b,         
 %        keywordstyle=[1]\textbf,    % Stil der Keywords
 %        keywordstyle=[2]\textbf,    %
 %        keywordstyle=[3]\textbf,    %
 %        keywordstyle=[4]\textbf,   \sqrt{\sqrt{}} %
         stringstyle=\color{black}\ttfamily, % Farbe der String
         showspaces=false,           % Leerzeichen anzeigen ?
         showtabs=false,             % Tabs anzeigen ?
         xleftmargin=17pt,
         framexleftmargin=17pt,
         framexrightmargin=5pt,
         framexbottommargin=4pt,
         %backgroundcolor=\color{lightgray},
         showstringspaces=false      % Leerzeichen in Strings anzeigen ?        
 }


\title{TD\_xxx:  Matlab code for simulation of floating body motions in the time domain}

\author{Andrew Hamilton \\ Copyright \copyright 2012 MBARI}
\date{}

\begin{document}
\thicklines
\lstset{language=Matlab}
\lstset{numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt}
\lstset{firstnumber=last}

\maketitle
\tableofcontents
\newpage
\section{Listings}
\begin{lstlisting}[frame=single,frameround=tttt,firstnumber=1]
load(['TwoBodyExample.mat']);

t = get(Buoy,'t');

%Incident Wave profile
eta0 = eta(wave,0,t);

%Get Buoy motion results
x = get(Buoy,'x');
xdot = get(Buoy,'xdot');
xddot = get(Buoy,'xddot');
 
%Get Plate motion results
y = get(Plate,'x');
ydot = get(Plate,'xdot');
yddot = get(Plate,'xddot');

%Get Forces

Bforce = get(Buoy,'Forces');
Fforce = get(Plate,'Forces');

\end{lstlisting}

\begin{lstlisting}[frame=single,frameround=tttt,firstnumber=31]
%Buoy kinematics
figure('Position', [100 100 1000 600])
set(gcf,'color','white');
subplot(3,1,1),plot(t,x(:,1),t,x(:,3),t,x(:,5));
title('Buoy Motions','FontName','times','FontSize', 12);
legend('surge(m)','heave(m)','pitch(rad)');

subplot(3,1,2),plot(t,xdot(:,1),t,xdot(:,3),t,xdot(:,5));
legend('surge vel (m/s)','heave vel (m/s)','pitch vel (m/s)');

subplot(3,1,3),plot(t,xddot(:,1),t,xddot(:,3),t,xddot(:,5));
legend('surge accel (m/s^2)','heave accel (m/s^2)','pitch accel (m/s^2)');
xlabel('time (s)');

\end{lstlisting}



\end{document}




