User:Eml4500.f08.gravy.jad/Matlab1

5. Matrix Building Functions

Some commonly used functions in Matlab consists of:

For example, by saying zeros(m,n) produces an mxn matrix containing zeros. By saying zeros(n) produces an nxn matrix containing zeros. By saying zeros(A) while A is an existing matrix, it produces a matrix size A containing zeros.

6. For, if, while -and relations

For, if and while are different types of loops used in Matlab.

for:

-The "for" loop produces a vector of size "n" for a given function "x"

-saying, i=n:-1:1, will write the vector backwards

-There can be double nested "for" loops (two or more for loops in the same loop. This will produce an mxn matrix.

-A matrix can be used instead of "n" and it will assume to compute the matrix

while:

-The "while" function is a loop that will continue to loop until the condition statement becomes false

if:

-The"if" function is a single loop that will only enter the loop if the primary condition is met

-it is a single loop

Relations

Some common relational operators used in Matlab consists of:

logical operators are as follows:

In addition, any true/false relations appear as a scalar number 1/0.

10. Command line editing and recall

- editing is easy -> backspace or delete to the right or left of the cursor

- commands: Ctl-a, Ctl-e, Ctl-d, Ctl-k for Unix or PC systems

- the cursor can be moved up or down to recall any previous line, therefore one can move the cursors up, down, left, right and recall and/or edit anything on the page

11. Submatrices and colon notation

-matlab uses vectors and submatrices, often generated by "colon notation"

- "colon notation" and subscripting is used to manipulate data sets

- ex: A(1:4,3) = matrix A, column 3, elements 1 through 4

A(:,3) = matrix A, column 3, all elements

A(:,[2 4]) = matrix A, column 2 and 4, all elements