{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Vectors - Vector Operations and Helpful Functions by Toshant

# Vectors - Vector Operations and Helpful Functions by...

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

Operations with Vectors For the purposes of the notes, please assume the following lines of code for the entire notes page: vec = [10 12 14 16]; vec1 = [1 2 3 4 5]; vec2 = [1 2 3 4]; vec3 = [1;2;3;4]; 1. Element by element operation a. Operations are done element by element. An example is shown below. b. vec4 = vec + 2; c. Each element of vec is increased by a value of 2. 2. General operations with vectors - There are two rules to basic vector operations. a. (1) If two vectors are being operated together, then they must be of the same length. b. myVec = vec1 + vec2; b.i. The line above is not legal. Notice how vec1 and vec2 are not the same size. Matlab will error. c. myVec = vec + vec2; c.i. Since there are four values in vec and vec2, and both vectors are horizontal, they can be legally added together. c.ii. Each value is added across the vector. Meaning the first value of vec is added to the first value of vec2. The second value of vec is added to the second value of vec2, and so on until the following solution is reached. c.iii. myVec -> [11 14 17 20] d. myVec = vec2 + vec3; d.i. Notice how vec2 and vec3 have the same number of values.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

Vectors - Vector Operations and Helpful Functions by...

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

View Full Document
Ask a homework question - tutors are online