review 2 exam 3 1. 1.history of computers 1. cpu stands for _______________________. a. counter...

28
REVIEW 2 Exam 3 1

Upload: katrina-moody

Post on 29-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

2.Getting Started with Matlab

Before coding anything, what are the 5 steps to follow?

S ________________________________

I ________________________________

M ________________________________

C ________________________________

T ________________________________

3

6. Outputs What are the three methods to display results? Which method allows to print results with a specific

format? What are the 4 placeholders? What is the purpose of placeholders? Which function actually uses placeholders? What are format modifiers? Which placeholder can have a format modifier that

controls the number of decimal places? If there are 3 placeholders in the format string, how

many variables are likely printed to the screen?9

7. Conditionals

What are the two conditionals shown that allow to skip code?

Regardless whether it is if or switch, which keyword is always associated with both?

What other keywords are associated with if? What other keywords are associated with switch?

10

8.Library Functions What are library functions? What are arguments? What are return-values? Is there a limit to the number of arguments a function

can receive? Is there a limit to the number of return-values a function

can have? Name 3 rounding functions? Which rounding function rounds towards +infinity? Which rounding function rounds towards -infinity? Which rounding function rounds towards the nearest

integer? 11

9. Loops

12

LoopsWHILEFORchoosing a loopinfinite loops

Changing control-loop variable in body

Range operatorRunning TotalsRunning Products

Using While loops to:• validate input• repeat the program – based on user’s

selection

Nesting Loops

Numerical Methods• Iterative solutions – “close enough” to

a solution. Remember to use abs()

10. Array

13

Array TerminologyTypes of arrays"row", "column"empty vector [ ]

Matrix MathDifferences for:

additionsubtractionmultiplicationdivisionexponentiation

Defining arraysHard-codedRange operatorlinspace()

Re-defining array elementsEliminating array elementsAugmenting arrays

Array buildingDiminishing arrays

Referencing arrays

Slices

10. Array

14

SearchingLinear search – “one by one”Binary search – “sorted search”

Matrix MathUsing scalarsUsing vectors & matricesvs. element-per-element

Logical operations

Logical vectors

Find the values - Logical indexing

Find the indices - find()Applying &, | to logical operations on arrays

Question

How many different ways to create the following vector a? what is the length of vector a? which function can be used to determine it? How to determine minimum or maximum value in vector a? and the location?

1 3 5 7 9

How to extract a new vector as 5 9?

15

12. Programmer defined function Overall Idea? Lots of advantages? Vocabulary

Function-header Function-definition Syntax? Filename? Directory? Keyword? Position of return-values and parameter list Using all the parameters Assigning all the return-Function-call Arguments vs. parameters Return-values

23