The following additions to the MATLAB HELP file have been made since the November, 1980, printing of the Users' Guide.
NEWS MATLAB NEWS dated May, 1981.
The new features added since the November, 1980, printing
of the Users' Guide include DIARY, EDIT, KRON, MACRO, PLOT,
RAT, TRIL, TRIU and six element-by-element operations:
.* ./ .\ .*. ./. .\.
Some additional capabilities have been added to EXIT,
RANDOM, RCOND, SIZE and SVD.
. 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.
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.
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.
EXIT Causes termination of a FOR or WHILE loop.
If not in a loop, terminates execution of MATLAB.
KRON KRON(X,Y) is the Kronecker tensor product of X and Y . It
is also denoted by X .*. Y . The result is a large matrix
formed by taking all possible products between the elements
of X and those of Y . For example, if X is 2 by 3, then
X .*. Y is
< x(1,1)*Y x(1,2)*Y x(1,3)*Y
x(2,1)*Y x(2,2)*Y x(2,3)*Y >
The five-point discrete Laplacian for an n-by-n grid can be
generated by
T = diag(ones(n-1,1),1); T = T + T'; I = EYE(T);
A = T.*.I + I.*.T - 4*EYE;
Just in case they might be useful, MATLAB includes
constructions called Kronecker tensor quotients, denoted by
X ./. Y and X .\. Y . They are obtained by replacing the
elementwise multiplications in X .*. Y with divisions.
MACRO The macro facility involves text and inward pointing angle
brackets. If STRING is the source text for any MATLAB
expression or statement, then
t = 'STRING';
encodes the text as a vector of integers and stores that
vector in t . DISP(t) will print the text and
>t<
causes the text to be interpreted, either as a statement or
as a factor in an expression. For example
t = '1/(i+j-1)';
disp(t)
for i = 1:n, for j = 1:n, a(i,j) = >t<;
generates the Hilbert matrix of order n.
Another example showing indexed text,
S = <'x = 3 '
'y = 4 '
'z = sqrt(x*x+y*y)'>
for k = 1:3, >S(k,:)<
It is necessary that the strings making up the "rows" of
the "matrix" S have the same lengths.
PLOT PLOT(X,Y) produces a plot of the elements of Y against
those of X . PLOT(Y) is the same as PLOT(1:n,Y) where n is
the number of elements in Y . PLOT(X,Y,P) or
PLOT(X,Y,p1,...,pk) passes the optional parameter vector P
or scalars p1 through pk to the plot routine. The default
plot routine is a crude printer-plot. It is hoped that an
interface to local graphics equipment can be provided.
An interesting example is
t = 0:50;
PLOT( t.*cos(t), t.*sin(t) )
RAND Random numbers and matrices. RAND(N) is an N by N matrix
with random entries. RAND(M,N) is an M by N matrix with
random entries. RAND(A) is the same size as A . RAND
with no arguments is a scalar whose value changes each time
it is referenced.
Ordinarily, random numbers are uniformly distributed in
the interval (0.0,1.0) . RAND('NORMAL') switches to a
normal distribution with mean 0.0 and variance 1.0 .
RAND('UNIFORM') switches back to the uniform distribution.
RAND('SEED') returns the current value of the seed for the
generator. RAND('SEED',n) sets the seed to n .
RAND('SEED',0) resets the seed to 0, its value when MATLAB
is first entered.
RAT An experimental function which attempts to remove the
roundoff error from results that should be "simple"
rational numbers.
RAT(X) approximates each element of X by a continued
fraction of the form
a/b = d1 + 1/(d2 + 1/(d3 + ... + 1/dk))
with k <= len, integer di and abs(di) <= max . The default
values of the parameters are len = 5 and max = 100.
RAT(len,max) changes the default values. Increasing either
len or max increases the number of possible fractions.
<A,B> = RAT(X) produces integer matrices A and B so that
A ./ B = RAT(X)
Some examples:
long
T = hilb(6), X = inv(T)
<A,B> = rat(X)
H = A ./ B, S = inv(H)
short e
d = 1:8, e = ones(d), A = abs(d'*e - e'*d)
X = inv(A)
rat(X)
display(ans)
RCOND RCOND(X) is an estimate for the reciprocal of the
condition of X in the 1-norm obtained by the LINPACK
condition estimator. If X is well conditioned, RCOND(X)
is near 1.0 . If X is badly conditioned, RCOND(X) is
near 0.0 .
<R, Z> = RCOND(A) sets R to RCOND(A) and also produces a
vector Z so that
NORM(A*Z,1) = R*NORM(A,1)*NORM(Z,1)
So, if RCOND(A) is small, then Z is an approximate null
vector.
SIZE If X is an M by N matrix, then SIZE(X) is <M, N> .
Can also be used with a multiple assignment,
<M, N> = SIZE(X) .
SVD Singular value decomposition. <U,S,V> = SVD(X) produces a
diagonal matrix S , of the same dimension as X and with
nonnegative diagonal elements in decreasing order, and
unitary matrices U and V so that X = U*S*V' .
By itself, SVD(X) returns a vector containing the singular
values.
<U,S,V> = SVD(X,0) produces the "economy size"
decomposition. If X is m by n with m > n, then only the
first n columns of U are computed and S is n by n .
TRIL Lower triangle. TRIL(X) is the lower triangular part of X.
TRIL(X,K) is the elements on and below the K-th diagonal of
X. K = 0 is the main diagonal, K > 0 is above the main
diagonal and K < 0 is below the main diagonal.
TRIU Upper triangle. TRIU(X) is the upper triangular part of X.
TRIU(X,K) is the elements on and above the K-th diagonal of
X. K = 0 is the main diagonal, K > 0 is above the main
diagonal and K < 0 is below the main diagonal.