Final+Exam+Review - FinalExamReview Spring2009...

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

View Full Document Right Arrow Icon
Final Exam Review Spring 2009
Image of page 1

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

View Full Document Right Arrow Icon
Topics Covered This  Semester: Vectors Conditionals and  Itteration Functions Strings Cell Arrays Structures and  Structure Arrays Arrays File I/O Recursion Plotting Bodies of Rotation Matrices Images Numerical Methods Sound  Sorting Queues  (Graph Search)
Image of page 2
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];    horizontally  concatenates vectors A, B, and C.
Image of page 3

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

View Full Document Right Arrow Icon
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) 
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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.
Image of page 6
Itteration: For loops !
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern