Final+Exam+Review

Final+Exam+Review - Final Exam Review Spring 2009 Topics...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Final Exam Review Spring 2009 Topics Covered This Semester: • Vectors • Conditionals and Itteration • Functions • Strings • Cell Arrays • Structures and Structure Arrays • Arrays • • Recursion • Plotting • Bodies of Rotation • Matrices • Images • Numerical Methods • Sound • Sorting • Queues (Graph Search) Vectors: We remember these right? Of course, you’ve been doing them all semester now! They contain only numerical values of class double. You can create them several ways, such as: 1. Colon Operator: x = 2:2:10; • x = [2 4 6 8 10]; 2. Manually using square brackets : • x = [1 2 3 4 5]; 3. Linspace: x = linspace(4, 20, 5) • x = [4 8 12 16 20]; • Remember linspace assumes 100 values if you do not specify in the third input parameter. 4. Concatenation: x = [A B C]; &#223; horizontally concatenates vectors A, B, and C. Indexing/Assignment : If you want to index the 2nd element in your vector: x = vec(2); If you have a vector, vec, and you want the third element to be a 4: vec(3) = 4; Or if you wish the 5th and 6th elements in your vector to be a 7 and an 8: vec([5 6]) = [7 8]; If you wish to remove the last 3 elements of the vector: vec(end-3:end) = [ ]; To get all even values from vec: new_vec = vec(mod(v1,2)==0) To get the values of all the even indices: new_vec=vec(2:2:end) Condtionals: Remember ‘if’ and ‘switch’ statements? ‘ if’ Statements: if <condition> <code> elseif <condition> <code> else <code> end *do NOT forget the end!! Switch Cases: switch <variable> case {‘option1’, ‘option2’} <code> case ‘option’ <code> othewise <code> end • We would use an if statement to test multiple things at once. For instance if we have several variables that play into the coding decision we need to make: • x needs to be larger than 5, y needs to be smaller than 7, and STR needs to be ‘hello world’ for us to add 6 to our vector, but if J is larger than 8 then we want to remove the last three letters from our string…. you see where this is going? Multiple variables are playing into the actions we are going to take. • We use Switch if we are testing a single variable, say X, for certain conditions to carry out certain code. • if we ‘switch x’ all of our cases are going to be wether ‘x’ is greater than, equal to, less than, true, false… ect. Itteration: For loops !...
View Full Document

This note was uploaded on 11/21/2011 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Page1 / 84

Final+Exam+Review - Final Exam Review Spring 2009 Topics...

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