Vectors - Vector Operations and Helpful Functions by Toshant

Vectors - Vector Operations and Helpful Functions by...

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

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

This note was uploaded on 02/28/2012 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

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 Right Arrow Icon
Ask a homework question - tutors are online