GLG410 Introduction to MatLab
We will use MATLAB for the rest of our class in conjunction with notes from
various sources and our textbook Middleton, 1999, Data analysis in the
earth sciences using Matlab, Prentice Hall.
help matlab demos
Using the matlab help function
matlab/general - General purpose commands.
matlab/ops - Operators and special characters.
matlab/lang - Programming language constructs.
matlab/elmat - Elementary matrices and matrix manipulation.
matlab/elfun - Elementary math functions.
matlab/specfun - Specialized math functions.
matlab/matfun - Matrix functions - numerical linear algebra.
toolbox/symbolic - Symbolic Math Toolbox.
toolbox/tour - MATLAB Tour
wavelet/wavelet - Wavelet Toolbox.
wavelet/wavedemo - Wavelet Toolbox Demos.
For more help on directory/topic, type "help topic".
Basic math function
Say we wanted to figure out some basic math function:
>> help matlab/elmat
and then in that output, we wanted to know how to create random numbers:
So let's make a simple coin flipper:
or, increase your chances, flip 4 at once:
What about clearing variables? CLEAR removes all variables from the workspace.
Download and view Professor Rankin's Matlab Guide:
once you save it to your directory, you will need to type:
darkwing% acroread &
that will launch the Adobe Acrobat Reader and then you can open the Matlab
Using Matlab For Geological
Working our way through that will be our main effort for our class and lab today.
Once you have made a graphic you like in MatLab, go to the file menu on
the graphics window and print it to a file:
Save the file to a name and location so you can find it. The file is a
postscript file so you can do a number of things to it including
darkwing% gs figure.ps
A NEW function we have is the convert command. It is pretty smart and it
will easily convert the *.ps to *.gif. NOTE that it only makes a gif
file. You have to use ghostscript to make a jpeg:
darkwing% convert figure.ps figure.gif
What is important is that the suffixes (*.ps and *.gif) are exactly as
shown because that is where convert goes to look and see what you want.
If you want to load a file that has some data in it, you thave to be in
the right directory or type the complete path name:
>> load /export/home2/ramon/glg410matlab/middleton_files/DEWIJS.DAT
to display the contents:
If you produce your own text file for matlab, ftp it onto darkwing (if you
did not produce it there), and then you can do the same to a file with one
entry per line:
darkwing% more dates
>> load dates
You will notice that the formatting is bad. The numbers look like they
have changed. Try
then you will see that if you type:
>>format long g
Using the diary function to record your Matlab session
See section R.1.6 from Professor Rankin's Matlab Guide.
Pages maintained by
Prof. Ramón Arrowsmith
Last modified January 18, 2000