Matlab_Basics - Matlab Basics Sequential Matlab has the...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Matlab Basics
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sequential
Background image of page 2
Matlab has the usual programming operators for forming expressions: The multiplication, division and power operators can be modified to perform “element-by-element” arithmetic on vectors and matrices of matching size. + Addition Subtraction * Multiplication / Division \ Left division (Solves Linear Equations) ^ Power ' Matrix-Vector Transpose ( ) Specify Evaluation Order
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Operators and Expressions With the exception of the unary minus sign, operators are binary operators. That is they act on two operands . The unary minus changes the sign of the the operand immediately following it. Unary Operation: -5 Binary Operation: 5+3 Expressions are made up of series of operators and operands. A + b + 5.6 / 2
Background image of page 4
When used in an extended sequence, operations are executed in a certain order controlled by “order of precedence” rules. Operations of equal precedence are evaluated from left to right. 1. Parentheses () 2. Transpose(') 3. Power(^, .^) 4. Unary plus (+), unary minus (-), logical negation (~) 5. Multiplication (*, .*), right division (/, . /), left division (\, .\) 6. Addition (+), subtraction (-) 7. Colon operator (:) 8. Less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=), equal to (==), not equal to (~=) 10.Logical OR (|)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Assignment Statements The “workhorse” operation in sequential processing is the assignment statement in which a right-hand side expression is equated to a left-hand side variable. A = b + 5 All quantities on the right-hand side must be defined before execution of the expression. If the left-hand side variable has previously been defined it will acquire the new value.
Background image of page 6
B = [2 1 5]; C = A . / B .^ 2 C = 0.7500 9.0000 0.2000 C = (A . / B) .^ 2 C = 2.2500 81.0000 1.0000 C = A + B . / B C = [4 10 6] C = ( A+B ) . / B ? A couple of examples:
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 29

Matlab_Basics - Matlab Basics Sequential Matlab has the...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online