Beruflich Dokumente
Kultur Dokumente
WHAT IS MATLAB?
Matlab is an interactive program for numerical computation and data visualization; it is used extensively by control engineers for analysis and design. There are many different toolboxes available which extend the basic functions of Matlab into different application areas. Matlab is supported on Unix, Macintosh, and Windows environments; a student version of Matlab is available for personal computers. For more information on Matlab, contact the Mathworks.
WHY MATLAB?
MATLAB is relatively easy to learn MATLAB code is optimized to be relatively quick when performing matrix operations MATLAB may behave like a calculator or as a programming language MATLAB is interpreted, errors are easier to fix.
MATLAB is NOT a general purpose programming language. MATLAB is an interpreted language (making it for the most part slower than a compiled language such as C++) MATLAB is designed for scientific computation and is not suitable for some things (such as parsing text).
MATRICES
One can see that this has 3 rows and 3 columns i.e. it is a 3 by 3 matrix.
Question: Is scalar number 5 a matrix for MATLAB? Answer: Yes number 5 is a 1 by 1 matrix. Creating a matrix is as easy as making a vector, using semicolons (;) to separate the rows of a matrix. If we type
A= [1 2 3; 4 5 6; 7 8 9]
Matlab will receive a matrix A in workspace. If we do A+Enter MATLAB will give what is stored in A. One area in which MATLAB excels is matrix computation. We can easily find the transpose of the matrix 'A'.
B = A'
Now let's multiply these two matrices together. Note again that MATLAB doesn't require you to deal with matrices as a collection of numbers. MATLAB knows when you are dealing with matrices and adjusts your calculations accordingly.
C=A*B
X = inv(A)
.. and then illustrate the fact that a matrix times its inverse is the identity matrix.
I = inv(A) * A
MATLAB has functions for nearly every type of common matrix calculation.
MATRIX OPERATIONS IN MATLAB It is possible to perform operations and commands on matrices. The following MATLAB operations are important. Multiplication
Matrix
Size
j= 1,2, n k= 1,2, p
where
So,
and
and
are . If may or
and
or
is a
number. Multiplication of a matrix by a number (scalar multiplication) results in multiplication of all matrix elements by that number. The symbol for matrix multiplication in MATLAB is *, i.e.,
>> A*B
Addition
>> A+B
and Subtraction:
>> A-B
of two matrices
and
of the matrix. In MATLAB, these operations are defined if the sizes of the matrices are the same or if one of the matrices is a scalar. In the latter case the scalar is added to or subtracted from every element of the matrix.
>> A^p
to the
power. If
is a positive integer,
is calculated by repeated
In MATLAB, the command transpose(A) or A' (the latter only for real valued matrices) calculates the
>> [1 2 3]'
forms the column matrix: >> 1 2 3 If the matrix contains complex, non-real, elements, then the command A' does not only with respect to the diagonal, but it also takes the complex conjugate of with respect to the diagonal,
every element. If you only want to calculate the reflection of you can do this with the command A.'.