%A Very Brief Intro to MatLab
%reference

\documentclass[12pt]{article}
\usepackage{times}
\pagestyle{empty}

\addtolength{\textwidth}{1.2in}
\addtolength{\textheight}{1.2in}
\addtolength{\oddsidemargin}{-.58in}
\addtolength{\evensidemargin}{-.58in}
\renewcommand{\baselinestretch}{1.0}
\parindent = 0cm
\parskip = .1cm

\begin{document}

\begin{center}
\Large
A Very Brief Intro to \textsc{MatLab} 
\footnote{Copyright \copyright 2002 Lindsay Eyink, Larry Snyder and Todd Young.
All rights reserved.
Please address comments to young@math.ohiou.edu.}

\large (Keep as a reference)
\end{center}

\vspace{.2cm}
{\bf A few general principles}
\begin{itemize}
\item Type commands at the prompt and press \fbox{Enter}.

\item Unless declared otherwise, variables are row vectors (1 by n arrays).

\item The command \verb$ syms x $ declares \verb$ x $ to be a symbolic variable.

\item \textsc{MatLab} is case sensitive, i.e. \verb$X$ $\not\equiv$ \verb$x$.

\item The command \verb$ clear $ will clear all variables. Always clear before starting
      a new computation. The command \verb$ clear $ will not clear the screen.

\item Ending a command with a semicolon ``\verb$;$" suppresses the output.

\item Enter all commands exactly as given in the assignments.

\item \verb$ans$ indicates the output from the preceeding command. Two useful commands 
	are\\
	\verb$ pretty(ans) $ and \verb$ simple(ans)$.

\item \textsc{MatLab} does both symbolic and numerical calculations. 

\item When you make a mistake, you do not have to retype the whole command. Use $\uparrow$
      and $\downarrow$ to return to a line,
      correct the errors and re-press \fbox{Enter}. (Sometimes you also need to \verb&clear&.) 

\item Access \verb$ Help $ by clicking \fbox{Help} $\rightarrow$ \fbox{Matlab Help}, or
      by typing \verb$ helpdesk $ or\\ \verb$ helpwin$.

\item Text may be added to your work after the symbol \verb$%$.

\item Save, print and exit by clicking the \fbox{File} icon.

\item Many advanced procedures may be accomplished using Toolboxes. See the reference
      manual for details.

\item \textsc{MatLab} may be used as a programming language.

\item There is an O.U. \textsc{MatLab} web page 
at: \verb& www.math.ohiou.edu/~matlab&, which contains 
assignments, reference materials and a sample solution to
an actual assignment. 

\item For a more details on \textsc{MatLab} and how to use it we suggest:
      {\em A Guide to MatLab for Beginners and Experienced Users}, by B.~Hunt, R.~Lipsman, and J.~Rosenberg,
      Cambridge Univeristy Press, New York, 2001. 

\end{itemize}

\newpage
\vspace{.5cm}
{\bf Some basic commands using a symbolic variable {\rm(try them)}.}
\begin{itemize}

\item \verb+syms x+		\dotfill This makes a symbolic variable.
\item \verb+f = x*sin(x)+	\dotfill This makes \verb+f+ a symbolic function.
\item \verb+f1 = diff(f)+	\dotfill \verb+f1+ - is the derivative of \verb+f+.
\item \verb+f2 = diff(f,2)+	\dotfill \verb+f2+ - This is the second derivative of \verb+f+.
\item \verb+F = int(f)+		\dotfill \verb+F+ - This is the antiderivative of \verb+f+.
\item \verb+int(f,0,pi)+	\dotfill This is a definite integral.
\item \verb+limit(log(cos(x))/x^2,0)+  \dotfill \textsc{MatLab} uses L'Hopital's rule to find limits.
\item \verb+limit(log(x)^2/x,inf)+  \dotfill Also for $\infty$ / $\infty$.
\item \verb+ezplot(f)+		\dotfill Plot a graph using the default interval.
\item \verb+ezplot(f,0,4*pi)+   \dotfill Plot a graph for specified interval.
\item \verb&polyn = x^5 - x^4 - 7*x^3 + x^2 + 6*x& \\
      \verb+factor(polyn)+ \\
      \verb+solve(polyn)+ \dotfill This solves the equation
      ``\verb&polyn = 0&''
\item \verb&expr = cos(x)^5 + sin(x)^4 + 2*cos(x)^2 - 2*sin(x)^2 - cos(2*x)&\\
      \verb+simple(expr)+
\item \verb&ode = 'Dx = -a*x'&\\
      \verb&dsolve(ode,'x(0)=3')& \dotfill This solves the initial value problem at x(0)=3.

\end{itemize}
\vspace{.5cm}
{\bf Some basic commands using arrays.}
\begin{itemize}
\item \verb+x = -2:.1:2;+  \dotfill
             Makes \verb+t+ a vector with entries from \verb$-2$ to \verb$2$  
             in \verb$.1$ increments.  \\
      \verb+f = inline('x.^3 - 2*x','x')+ \dotfill Defines a function $f(x) = x^3 - 2x$. \\
      \verb+y = f(x)+   \dotfill 
             This evaluates \verb$f(x)$ for each entry of \verb$x$. \\
      \verb+plot(x,y)+   \dotfill
             This plots the pairs of points \verb$(x(k), y(k))$ for
             \verb$k = 1, 2,...$
\item \verb&x = -2:.05:2; y = x;& \\
      \verb&Z = sin(x'*y); mesh(Z) & \dotfill \verb&& ' means transpose.\\
              A figure window will appear with a
              graph. Click on \fbox{Tools} and select \fbox{Rotate 3D}.
              Point the cursor at the graph and ``click and drag" to rotate
              the graph.
\item \verb&A = [1 2 3; 4 5 6; 7 8 10],  C = [1 2; 3 4; 5 6]&\\
      \verb&A*C& \dotfill multiplies the matrices.\\
      \verb&b = [1 2 3]', A\b& \dotfill solves \verb$Ax = b$ by Gaussian
            elimination.

\end{itemize}

\end{document}
