E7_Lecture4_Su10+posted

# E7_Lecture4_Su10+posted - Vector addition(and subtraction...

This preview shows pages 1–5. Sign up to view the full content.

E7 L3 1 If A and B are arrays of the same size , A + B is the array: A(i) + B(i) Example: Vector addition (and subtraction) Vector addition (and subtraction) >> A + B ans = -1 3 >> A - B ans = -5 1 >> A = [-3 2]; >> B = [2 1]; 3 2 1 - + = - 2 1 3 + =

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

View Full Document
E7 L3 2 Vector – scalar addition (and subtraction) Vector – scalar addition (and subtraction) If A is an arra y, and b is a scalar A + b = b + A is the same size as A : A(i)+ b Example: >> A + b ans = -1 4 >> A - b ans = -5 0 >> A = [-3 2]; >> b = 2; 3 2 1 - + = - 2 2 4 + =
E7 L3 3 If A and B are arrays of the same size , A .* B = B .* A is the array: A(i) * B(i) Example: Array Array Element-by-Element Element-by-Element Multiplication Multiplication .* .* >> A .* B ans = -6 2 >> B .* B ans = 4 1 >> A = [-3 2]; >> B = [2 1]; 3 2 6 - × = - 2 1 2 × =

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

View Full Document
4 Scalar-Array Multiplication Scalar-Array Multiplication If A is an arra y, and b is a scalar A .* b = b .* A the same size as A : A(i)* b
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}