Array_Processing

# Array_Processing - Array Processing How would we start to...

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

Array Processing

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

View Full Document
How would we start to arrange the following values in ascending order? 95 24 61 49 89 76 46 30 82 45 These might represent a set of grades or some other numbers that have something in common. Most programming languages have methods for defining and manipulating arrays of values. MATLAB was designed to work easily with one dimensional and multidimensional arrays
Defining a vector (Row vector) MATLAB is a tool for doing computations with vectors & matrices » v1 = [2 3, 3] v1 = 2 3 3 » length (v1) ans = 3 Name of vector You can use either a space or comma to separate the elements in vector definition Square bracket Reports the number of elements in a vector

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

View Full Document
Defining a vector (Column vector) Similar you can also define a column vector » c1 = [1;3;2] c1 = 1 3 2 Use semicolon to change rows Square bracket
Vectors Vectors are one dimensional arrays of items. = n x x x x x 3 2 1 x is a column vector: [ ] m y y y y y 3 2 1 = y is a row vector: The individual entries in a vector are called elements.

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

View Full Document
Transpose Operator It waste a lot of space to write large column vectors another way to write x is: [ ] T 3 2 1 n x x x x x = The T is the transpose operator. It changes the rows of a vector (or matrix) into columns and vice-versa.
The Matlab colon operator can be used to create vectors whose elements form a series: y = start : stop z = start : increment : stop [ ] 6 5 4 3 2 6 : 2 = = y [ ] 6 . 5 5 4 . 4 8 . 3 2 . 3 6 . 2 2 6 : 6 . 0 : 2 = = z

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

View Full Document
Creating Vectors with Constant Spacing and Known Element Count vname = linspace( xi, xf, n ) xi is first element xf is last element n is number of elements in vector omitted n gives 100 elements >> z = linspace( 1, 5, 9 ) z = 1 1.5 2 2.5 3 3.5 4 4.5 5
Vector Operations Assume two column vectors x and y: = n x x x x x 3 2 1 = n y y y y y 3 2 1

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

View Full Document
Summation ± ± ± = ± n n i i y x y x y x y x 1 1 Summation is done element-by-element (a Matlab term) The vectors must be of the same type and length
Scalar Addition + + + = + a x a x a x a x n i 1 The scalar is added to each element in the vector.

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

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

## This note was uploaded on 07/26/2009 for the course CHE 210 taught by Professor Swinnea during the Fall '08 term at University of Texas at Austin.

### Page1 / 40

Array_Processing - Array Processing How would we start to...

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

View Full Document
Ask a homework question - tutors are online