User:Eml4500.f08.gravy.bje/MATLAB

1. Accessing MATLAB
After MATLAB is installed to the computer, it may be accessed either by clicking on a icon on the desktop, or if that icon was not created, by selecting the icon in the start menu. An alternate method to access MATLAB is to enter it into the system command which can also be found in the start menu

For convenience, MATLAB, as well as the local editor should both remain open in separate windows for any computer system that allows for multiple processes. Any questions in this area should be directed towards the computer manufacturer.

2. Entering Matrices
Matrices are the method by which MATLAB represents all variables. Single variables or interpreted as a 1 x 1 matrix, with no indicated direction. This is also known as a scalar quantity. A vector is represented by any matrix consisting of one column, or one row. All matrices are two dimensional and must consist of numerical values.

There are multiple methods by which to introduce a matrix into MATLAB including loading the matrix from a disk or file, inserting the matrix manually, or using a matrix that has been generated by another mathematical equation. The following two statements are examples of the correct syntax to generate a 3 x 3 matrix:

A = [1 2 3; 4 5 6; 7 8 9]

A= [ 1 2 3 4 5 6 7 8 9] The first example separates the values by spaces and the rows by semi-colons while the second separates the rows by lines.

To indicate an exponent, values must be entered in without spaces (i.e. 2.34e-5) for proper syntax. MATLAB also has the ability to interpret imaginary numbers using i and j. These values are also entered without spaces (i.e. 3+4i). If the values of i and j are assigned prior to their use as an imaginary value, a new value can be used by first setting it equal to the square root of negative one.

If a matrix is too long and tedious to enter manually it should be entered via an ASCII file from the local editor to avoid possible error from input. To load files in MATLAB, use the load command followed by the name of the file.

For example: load filename.ext If a user wishes to experiment with matrices of random numbers the rand, magic, and hilb functions provide a solution. The rand function creates a matrix of randomly generated numbers for a matrix with the same number of rows as columns. The magic function creates a magic square matrix. This is a particular type of matrix where the rows, columns, and diagonals have a common sum. The hilb function creates a Hilbert matrix.

3. Matrix and Array Operations
MATLAB has a variety of operations available including addition (+), subtraction (-), multiplication (*), power (^), conjugate transpose (‘), left division (\), and right division (/) all of which can be applied to both scalars and vectors. Order of operations applies.

7. Scalar Functions
There are some functions in MATLAB that were designed and created for scalar functions. These functions can still operate element-wise on matrices. Some common examples are sin, cos, tan, asin, acos, atan, exp, log, ln, rem (remainder), abs (absolute value), sqrt (square root)

8. Vector Functions
Unlike scalar functions, vector functions are, as their name hints, used on vectors (i.e. matrices or size m x n). These functions when used yield answers which are also in vector form. Some common examples of vector functions are max (max value), min (min value), sort (sort values), median, mean, std (standard deviation), sum, prod (product)

9. Matrix Functions
As mentioned above, matrices are used as a representation of variables in MATLAB. This is what makes the program such a useful tool. Some common examples of matrix functions are eig (eigenvalues), chol (choleski factorization), inv (inverse), hess (hessenberg form), det (determinant)

Eigenvalues: eig Cholesky factorization: chol Inverse: inv Hessenberg form: hess Determinant: det