page@swan.ulowell.edu (Bob Page) (11/03/88)
Submitted-by: strovink%galaxy-43@afit-ab.arpa (Mark A. Strovink)
Posting-number: Volume 2, Issue 48
Archive-name: applications/matlab/help.1
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# readme
# help-1
# This archive created: Wed Nov 2 16:23:14 1988
cat << \SHAR_EOF > readme
MATLAB stands for MATrix LABoratory. It is a FORTRAN package developed by
Argonne National Laboratories for in-house use. It provides comprehensive
vector and tensor operations in a package which may be programmed, either
through a macro language or through execution of script files.
Matlab is reentrant and recursive. Functions supported include (but not
by any means limited to) sin, cos, tan, arcfunctions, upper triangular,
lower triangular, determinants, matrix multiplication, identity, hilbert
matrices, eigenvalues and eigenvectors, matrix roots and products, inversion
and so on and so forth.
The file available on the bulletin board as Matlab.arc contains an Amiga-ized
executable copy of MATLAB and the online help file, as well as this intro.
If you want the source code (over 300K) and a manual, or if your bulletin
board only has this message and not the package, send $5.00 and a 3.5"
disk to:
Jim Locker
4443 N. Hyland Ave.
Dayton, Oh 45424
The package is public domain, but of course postage and reproduction cost
money. Believe me, this package is a bargain at the price. Please feel free
to distribute the package.
The source was taken off a VAX 11/780. It ran without modification (except the
file handler and some minor error handling) on an Amiga 1000 using ABSoft
Fortran v2.2. It will run in 512K environment. I have seen it on IBM
mainframes and IBM PCs.
********************** A Sample Session ***********************************
For this session the <> character is the MATLAB prompt.
<> a=<1 2 3;5 4 6;7 8 9> <--- you enter this
A = <--- MATLAB response
1. 2. 3.
5. 4. 6.
7. 8. 9.
<> b=<5;6;7> <--- you enter this
B = <--- MATLAB response
5.
6.
7.
<> a*b <--- you enter "multiply a and b"
ANS = <--- MATLAB response
38.
91.
146.
<> b*a <---you enter "multiply b and a"
/--ERROR <--- MATLAB response
INCOMPATIBLE FOR MULTIPLICATION
<> det(a) <--- Take the determinant of a
ANS = <---MATLAB response
18.
<> exit <--- you quit MATLAB
total flops 34
ADIOS
SHAR_EOF
cat << \SHAR_EOF > help-1
Appendix. The HELP document
NEWS MATLAB NEWS dated 8/5/88 .
MATLAB has been ported to the Amiga in August 1988. This is a
straight port of VAX FORTRAN source with no enhancements. Possible
Amiga enhancements (depending upon how many folks are interested)
include Workbench startup and a greatly enhanced PLOT function.
I dunno...maybe.
If you would like a copy of MATLAB source and the users guide,
send a 3.5 disk and $5.00 american to:
Jim Locker
4443 N. Hyland Ave.
Dayton Oh 45424
You aren't paying me for developing the stuff (I didn't...Argonne
National Labs did. I just ported it), you are paying for postage
and the cost of copying the manual.
INTRO Welcome to MATLAB.
Here are a few sample statements:
A = <1 2; 3 4>
b = <5 6>'
x = A\b
<V,D> = eig(A), norm(A-V*D/V)
help \ , help eig
exec('demo',7)
For more information, see the MATLAB Users' Guide which is
contained in file ... or may be obtained from Jim Locker.
See the HELP NEWS section.
HELP HELP gives assistance.
HELP HELP obviously prints this message.
To see all the HELP messages, list the file ... .
< < > Brackets used in forming vectors and matrices.
<6.9 9.64 SQRT(-1)> is a vector with three elements
separated by blanks. <6.9, 9.64, sqrt(-1)> is the same
thing. <1+I 2-I 3> and <1 +I 2 -I 3> are not the same.
The first has three elements, the second has five.
<11 12 13; 21 22 23> is a 2 by 3 matrix . The semicolon
ends the first row.
Vectors and matrices can be used inside < > brackets.
<A B; C> is allowed if the number of rows of A equals
the number of rows of B and the number of columns of A
plus the number of columns of B equals the number of
columns of C . This rule generalizes in a hopefully
obvious way to allow fairly complicated constructions.
A = < > stores an empty matrix in A , thereby removing it
from the list of current variables.
For the use of < and > on the left of the = in multiple
assignment statements, see LU, EIG, SVD and so on.
In WHILE and IF clauses, <> means less than or greater
than, i.e. not equal, < means less than, > means greater
than, <= means less than or equal, >= means greater than or
equal.
For the use of > and < to delineate macros, see MACRO.
> See < . Also see MACRO.
( ( ) Used to indicate precedence in arithmetic expressions
in the usual way. Used to enclose arguments of functions
in the usual way. Used to enclose subscripts of vectors
and matrices in a manner somewhat more general than the
usual way. If X and V are vectors, then X(V) is
<X(V(1)), X(V(2)), ..., X(V(N))> . The components of V
are rounded to nearest integers and used as subscripts. An
error occurs if any such subscript is less than 1 or
greater than the dimension of X . Some examples:
X(3) is the third element of X .
X(<1 2 3>) is the first three elements of X . So is
X(<SQRT(2), SQRT(3), 4*ATAN(1)>) .
If X has N components, X(N:-1:1) reverses them.
The same indirect subscripting is used in matrices. If V
has M components and W has N components, then A(V,W)
is the M by N matrix formed from the elements of A whose
subscripts are the elements of V and W . For example...
A(<1,5>,:) = A(<5,1>,:) interchanges rows 1 and 5 of A .
) See ( .
= Used in assignment statements and to mean equality in WHILE
and IF clauses.
. Decimal point. 314/100, 3.14 and .314E1 are all the
same.
Element-by-element multiplicative operations are obtained
using .* , ./ , or .\ . For example, C = A ./ B is the
matrix with elements c(i,j) = a(i,j)/b(i,j) .
Kronecker tensor products and quotients are obtained with
.*. , ./. and .\. . See KRON.
Two or more points at the end of the line indicate
continuation. The total line length limit is 1024
characters.
, Used to separate matrix subscripts and function arguments.
Used at the end of FOR, WHILE and IF clauses. Used to
separate statements in multi-statement lines. In this
situation, it may be replaced by semicolon to suppress
printing.
; Used inside brackets to end rows.
Used after an expression or statement to suppress printing.
See SEMI.
\ Backslash or matrix left division. A\B is roughly the
same as INV(A)*B , except it is computed in a different
way. If A is an N by N matrix and B is a column vector
with N components, or a matrix with several such columns,
then X = A\B is the solution to the equation A*X = B
computed by Gaussian elimination. A warning message is
printed if A is badly scaled or nearly singular.
A\EYE produces the inverse of A .
If A is an M by N matrix with M < or > N and B is a
column vector with M components, or a matrix with several
such columns, then X = A\B is the solution in the least
squares sense to the under- or overdetermined system of
equations A*X = B . The effective rank, K, of A is
determined from the QR decomposition with pivoting. A
solution X is computed which has at most K nonzero
components per column. If K < N this will usually not be
the same solution as PINV(A)*B .
A\EYE produces a generalized inverse of A .
If A and B have the same dimensions, then A .\ B has
elements a(i,j)\b(i,j) .
Also, see EDIT.
/ Slash or matrix right division. B/A is roughly the same
as B*INV(A) . More precisely, B/A = (A'\B')' . See \ .
IF A and B have the same dimensions, then A ./ B has
elements a(i,j)/b(i,j) .
Two or more slashes together on a line indicate a logical
end of line. Any following text is ignored.
' Transpose. X' is the complex conjugate transpose of X .
Quote. 'ANY TEXT' is a vector whose components are the
MATLAB internal codes for the characters. A quote within
the text is indicated by two quotes. See DISP and FILE .
+ Addition. X + Y . X and Y must have the same dimensions.
- Subtraction. X - Y . X and Y must have the same
dimensions.
* Matrix multiplication, X*Y . Any scalar (1 by 1 matrix)
may multiply anything. Otherwise, the number of columns of
X must equal the number of rows of Y .
Element-by-element multiplication is obtained with X .* Y .
The Kronecker tensor product is denoted by X .*. Y .
Powers. X**p is X to the p power. p must be a
scalar. If X is a matrix, see FUN .
: Colon. Used in subscripts, FOR iterations and possibly
elsewhere.
J:K is the same as <J, J+1, ..., K>
J:K is empty if J > K .
J:I:K is the same as <J, J+I, J+2I, ..., K>
J:I:K is empty if I > 0 and J > K or if I < 0 and J < K .
The colon notation can be used to pick out selected rows,
columns and elements of vectors and matrices.
A(:) is all the elements of A, regarded as a single
column.
A(:,J) is the J-th column of A
A(J:K) is A(J),A(J+1),...,A(K)
A(:,J:K) is A(:,J),A(:,J+1),...,A(:,K) and so on.
For the use of the colon in the FOR statement, See FOR .
ABS ABS(X) is the absolute value, or complex modulus, of the
elements of X .
ANS Variable created automatically when expressions are not
assigned to anything else.
ATAN ATAN(X) is the arctangent of X . See FUN .
BASE BASE(X,B) is a vector containing the base B representation
of X . This is often used in conjunction with DISPLAY.
DISPLAY(X,B) is the same as DISPLAY(BASE(X,B)). For
example, DISP(4*ATAN(1),16) prints the hexadecimal
representation of pi.
CHAR CHAR(K) requests an input line containing a single
character to replace MATLAB character number K in the
following table. For example, CHAR(45) replaces backslash.
CHAR(-K) replaces the alternate character number K.
K character alternate name
0 - 9 0 - 9 0 - 9 digits
10 - 35 A - Z a - z letters
36 blank
37 ( ( lparen
38 ) ) rparen
39 ; ; semi
40 : | colon
41 + + plus
42 - - minus
43 * * star
44 / / slash
45 \ $ backslash
46 = = equal
47 . . dot
48 , , comma
49 ' " quote
50 < [ less
51 > ] great
CHOL Cholesky factorization. CHOL(X) uses only the diagonal
and upper triangle of X . The lower triangular is assumed
to be the (complex conjugate) transpose of the upper. If
X is positive definite, then R = CHOL(X) produces an
upper triangular R so that R'*R = X . If X is not
positive definite, an error message is printed.
CHOP Truncate arithmetic. CHOP(P) causes P places to be chopped
off after each arithmetic operation in subsequent
computations. This means P hexadecimal digits on some
computers and P octal digits on others. CHOP(0) restores
full precision.
CLEAR Erases all variables, except EPS, FLOP, EYE and RAND.
X = <> erases only variable X . So does CLEAR X .
COND Condition number in 2-norm. COND(X) is the ratio of the
largest singular value of X to the smallest.
CONJG CONJG(X) is the complex conjugate of X .
COS COS(X) is the cosine of X . See FUN .
DET DET(X) is the determinant of the square matrix X .
DIAG If V is a row or column vector with N components,
DIAG(V,K) is a square matrix of order N+ABS(K) with the
elements of V on the K-th diagonal. K = 0 is the main
diagonal, K > 0 is above the main diagonal and K < 0 is
below the main diagonal. DIAG(V) simply puts V on the
main diagonal.
eg. DIAG(-M:M) + DIAG(ONES(2*M,1),1) + DIAG(ONES(2*M,1),-1)
produces a tridiagonal matrix of order 2*M+1 .
IF X is a matrix, DIAG(X,K) is a column vector formed
from the elements of the K-th diagonal of X .
DIAG(X) is the main diagonal of X .
DIAG(DIAG(X)) is a diagonal matrix .
DIARY DIARY('file') causes a copy of all subsequent terminal
input and most of the resulting output to be written on the
file. DIARY(0) turns it off. See FILE.
DISP DISPLAY(X) prints X in a compact format. If all the
elements of X are integers between 0 and 51, then X is
interpreted as MATLAB text and printed accordingly.
Otherwise, + , - and blank are printed for positive,
negative and zero elements. Imaginary parts are ignored.
DISP(X,B) is the same as DISP(BASE(X,B)).
EDIT There are no editing features available on most
installations and EDIT is not a command. However, on a few
systems a command line consisting of a single backslash \
will cause the local file editor to be called with a copy
of the previous input line. When the editor returns
control to MATLAB, it will execute the line again.
EIG Eigenvalues and eigenvectors.
EIG(X) is a vector containing the eigenvalues of a square
matrix X .
<V,D> = EIG(X) produces a diagonal matrix D of
eigenvalues and a full matrix V whose columns are the
corresponding eigenvectors so that X*V = V*D .
ELSE Used with IF .
END Terminates the scope of FOR, WHILE and IF statements.
Without END's, FOR and WHILE repeat all statements up to
the end of the line. Each END is paired with the closest
previous unpaired FOR or WHILE and serves to terminate its
scope. The line
FOR I=1:N, FOR J=1:N, A(I,J)=1/(I+J-1); A
would cause A to be printed N**2 times, once for each new
element. On the other hand, the line
FOR I=1:N, FOR J=1:N, A(I,J)=1/(I+J-1); END, END, A
will lead to only the final printing of A .
Similar considerations apply to WHILE.
EXIT terminates execution of loops or of MATLAB itself.
EPS Floating point relative accuracy. A permanent variable
whose value is initially the distance from 1.0 to the next
largest floating point number. The value is changed by
CHOP, and other values may be assigned. EPS is used as a
default tolerance by PINV and RANK.
EXEC EXEC('file',k) obtains subsequent MATLAB input from an
external file. The printing of input is controlled by the
optional parameter k .
If k = 1 , the input is echoed.
If k = 2 , the MATLAB prompt <> is printed.
If k = 4 , MATLAB pauses before each prompt and waits for a
null line to continue.
If k = 0 , there is no echo, prompt or pause. This is the
default if the exec command is followed by a semicolon.
If k = 7 , there will be echos, prompts and pauses. This is
useful for demonstrations on video terminals.
If k = 3 , there will be echos and prompts, but no pauses.
This is the the default if the exec command is not followed
by a semicolon.
EXEC(0) causes subsequent input to be obtained from the
terminal. An end-of-file has the same effect.
EXEC's may be nested, i.e. the text in the file may contain
EXEC of another file. EXEC's may also be driven by FOR and
WHILE loops.
EXIT Causes termination of a FOR or WHILE loop.
If not in a loop, terminates execution of MATLAB.
EXP EXP(X) is the exponential of X , e to the X . See FUN
.
EYE Identity matrix. EYE(N) is the N by N identity matrix.
EYE(M,N) is an M by N matrix with 1's on the diagonal and
zeros elsewhere. EYE(A) is the same size as A . EYE
with no arguments is an identity matrix of whatever order
is appropriate in the context. For example, A + 3*EYE
adds 3 to each diagonal element of A .
FILE The EXEC, SAVE, LOAD, PRINT and DIARY functions access
files. The 'file' parameter takes different forms for
different operating systems. On most systems, 'file' may
be a string of up to 32 characters in quotes. For example,
SAVE('A') or EXEC('matlab/demo.exec') . The string will be
used as the name of a file in the local operating system.
On all systems, 'file' may be a positive integer k less
than 10 which will be used as a FORTRAN logical unit
number. Some systems then automatically access a file with
a name like FORT.k or FORk.DAT. Other systems require a
file with a name like FT0kF001 to be assigned to unit k
before MATLAB is executed. Check your local installation
for details.
FLOPS Count of floating point operations.
FLOPS is a permanently defined row vector with two
elements. FLOPS(1) is the number of floating point
operations counted during the previous statement. FLOPS(2)
is a cumulative total. FLOPS can be used in the same way
as any other vector. FLOPS(2) = 0 resets the cumulative
total. In addition, FLOPS(1) will be printed whenever a
statement is terminated by an extra comma. For example,
X = INV(A);,
or
COND(A), (as the last statement on the line).
HELP FLPS gives more details.
FLPS More detail on FLOPS.
It is not feasible to count absolutely all floating point
operations, but most of the important ones are counted.
Each multiply and add in a real vector operation such as a
dot product or a 'saxpy' counts one flop. Each multiply
and add in a complex vector operation counts two flops.
Other additions, subtractions and multiplications count one
flop each if the result is real and two flops if it is not.
Real divisions count one and complex divisions count two.
Elementary functions count one if real and two if complex.
Some examples. If A and B are real N by N matrices, then
A + B counts N**2 flops,
A*B counts N**3 flops,
A**100 counts 99*N**3 flops,
LU(A) counts roughly (1/3)*N**3 flops.
FOR Repeat statements a specific number of times.
FOR variable = expr, statement, ..., statement, END
The END at the end of a line may be omitted. The comma
before the END may also be omitted. The columns of the
expression are stored one at a time in the variable and
then the following statements, up to the END, are executed.
The expression is often of the form X:Y, in which case its
columns are simply scalars. Some examples (assume N has
already been assigned a value).
FOR I = 1:N, FOR J = 1:N, A(I,J) = 1/(I+J-1);
FOR J = 2:N-1, A(J,J) = J; END; A
FOR S = 1.0: -0.1: 0.0, ... steps S with increments of -0.1 .
FOR E = EYE(N), ... sets E to the unit N-vectors.
FOR V = A, ... has the same effect as
SHAR_EOF
# End of shell archive
exit 0
--
Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page
Have five nice days.