MatLab Links
- Matlab Tips from Caleb Bonilla
- Mathworks.com
- Mastering MatLabs
- Mathlab demos from Steve Maddox at University of Nottingham
- CS170a Mathematical Models and Methods for Computer Science
Winter 2003 by D. Stott Parker at UCLA
with many MathLab and Maple Resource links - Matlab Tutorial from Math.utah.edu
- Matlab Tutorial from glue.umd.edu - also links to other tutorials including Math.utah.edu
- Numerit less expensive program than Matlab
- Matlab at Indiana U including ref to Numerit, links to lots of Matlab resources...
- MAXIMA favorably compared to Mathematica in
OOoforum OpenOffice.org Forum 25 Nov 2003
MAXIMA is the original Lisp symbolic math program that gave rise to Mathematica
has Great Lisp links too. - Freshmeat survey Scientific/Engineering --> Mathematics
- PARI/GP multiprecision number theory environment can use GNU Multiple Precision Arithmetic Library GMP
- Freshmeat:FrAid (Fr[actal] Aid)
- G. Keady's involvement with Mathematica at University of Western Australia Maths/Engineering/Physics
- Math Resource Linkst
- Mathematical Resources on the Web per ufl.edu
MatLab Primer
by Kermit Sigmon and Timothy A. Davis
many fundamental data type (classes) in MATLAB, each one a Multidimenstional array.!
A Matrix of one row or one column is a vector (row vectors and column vectors behave differently;
they are more than one-dimensional arrays) A 1-by-1 matrix is called a scalar.
variable = expression or simply expression, where expressions are composed from
operators, functions, and variable names. Evaluation of the expression produces a matrix.
omit variable = and the result is stored in ans automatically!
you can save the command windows dialog with the diary command:
diary filename which causes everything that appears subsequently on the screen
to be written to the named file, or if no file is named, to a default file diary.
Until dairy off. to resume recording to diary file, diary on.
Check out help cedit for info on command-line editing.
who lists variables currently in the workspace.
clear variablename removes the variable from the workspace; clear alone removes
all non-permanent variables.
you can also right click on a variable in the Workspace Editor...
when you logout or exit MaTLAB, all variables are lost. However, you can invoke save and all variables will be written to a machine-readable file, matlab.mat. In a later MATLAB session, load restores the variables.
save myfile.mat works as expected...
Array Editor, a spreadsheet for matrices!. in workspace window, dbl-click on a matrix...
The Current Directory is where Matlab looks for M-files and for workspace (.mat) files that you load and save.
create a file (any text editory) called mymatrix.txt with two lines:
22 67 12 33load mymatrix.txt and the matrix will be loaded from the current directory to the variable mymatrix (file extension .txt in this example can be anything except .mat)
dirlists the contents of the current working directory...
MatLab Notes
MatLab notes Enter a magic square from the Renaissance engraving Melancholia I by the German artist and amateur mathematician Albrecht Dürer. A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1] sum(A) returns sums of columns (all 4 = 34) A' is transpose of A; result is implicity put in variable ans sum(A')' produces column of 34s - the result of transposing column sums on A' diag(A) produces diagonal terms list sum(diag(A)) sums diag terms = 34 It is also possible to refer to the elements of a matrix with a single subscript, A(k). This is the usual way of referencing row and column vectors. But it can also apply to a fully two-dimensional matrix, in which case the array is regarded as one long column vector formed from the columns of the original matrix. So, for our magic square, A(8) is another way of referring to the value 15 stored in A(4,2). A = magic(3) eig(A) poly(A) inv(A) ans * A life
simple algebra (neeb,noob,nub problem of 6-3-2003) A = [1 1 0; 1 0 1; 0 1 1] b = inv(A) -> b = 0.5000 0.5000 -0.5000 0.5000 -0.5000 0.5000 -0.5000 0.5000 0.5000 r = [3 4 5] b * r' -> ans = 1 2 3 A * b -> ans = 1 0 0 0 1 0 0 0 1 From math.utah.edu, Matlab tutorial Finally, we will do a little piece of programming. Let a be the matrix 0.8 0.1 0.2 0.9 and let x be the column vector 1 0 We regard x as representing (for example) the population state of an island. The first entry (1) gives the fraction of the population in the west half of the island, the second entry (0) give the fraction in the east half. The state of the population T units of time later is given by the rule y = ax. This expresses the fact that an individual in the west half stays put with probability 0.8 and moves east with probability 0.2 (note 0.8 + 0.2 = 1), and the fact that in individual in the east stays put with probability 0.9 and moves west with probability 0.1. Thus, successive population states can be predicted/computed by repeated matrix multiplication. This can be done by the following Matlab program: >> a = [ 0.8 0.1; 0.2 0.9 ] >> x = [ 1; 0 ] >> for i = 1:20, x = a*x, end What do you notice? Is there an explanation? Is there a lesson to be learned? To make a graph of y = sin(t) on the interval t = 0 to t = 10 we do the following: >> t = 0:.3:10; >> y = sin(t); >> plot(t,y) The command t = 0:.3:10; defines a vector with components ranging from 0 to 10 in steps of 0.3. The y = sin(t); defines a vector whose components are sin(0), sin(0.3), sin(0.6), etc. Finally, plot(t,y) use the vector of t and y values to construct the graph. Functions of two variables Here is how we graph the fuction z(x,y) = x exp( - x^2 - y^2): >> [x,y] = meshdom(-2:.2:2, -2:.2:2); >> z = x .* exp(-x.^2 - y.^2); >> mesh(z) The first command creates a matrix whose entries are the points of a grid in the square -2 <= x <= 2, -2 <= y <= 2. The small squares which make up the grid are 0.2 units wide and 0.2 unit tall. The second command creates a matrix whose entries are the values of the function z(x,y) at the grid points. The third command uses this information to construct the graph.
back to Index | back to Links |
last updated 9-26-2002,
6-4-2003, 12-12-2003, 8-5-2004, 12-16-2004 dek