{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

14-440-127 Lecture 6 Presentation

# 14-440-127 Lecture 6 Presentation - 14:440:127 Introduction...

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

14:440:127 Introduction to Computers for Engineers Lecture 6 Lecturer: Blase E. Ur Recitation Instructor: Tianming Li Recitation Instructor: Ke Xu Recitation Instructor: Brian Viezbicke Recitation Instructor: Mingliang Wang PLEASE TAKE LECTURE 6 NOTES AS YOU ENTER THE ROOM

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

View Full Document
Rutgers University SOE 14:440:127 Lecture 6 Loops disp(1) disp(2) disp(3) disp(4) disp(5) disp(6) disp(7) disp(8) disp(9)

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

View Full Document
Rutgers University SOE 14:440:127 Lecture 6 Loops Hit drum Hit drum Hit drum Hit drum Hit drum Hit drum Hit drum Hit drum Hit drum Hit drum
Rutgers University SOE 14:440:127 Lecture 6 For Loop for VARIABLE = VECTOR STATEMENTS end for i = 1 : 100 disp(i) end • First time through the loop, i=1 • Then, go back to the top; i=2 • … • The last time through the loop, i=100

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

View Full Document
Rutgers University SOE 14:440:127 Lecture 6 For Loop for VARIABLE = VECTOR STATEMENTS end for x = 1:6 hit_drum( ); end
Rutgers University SOE 14:440:127 Lecture 6 Sum 1 to 100 with a for loop s = 0; for z = 1:100 s = s+z; end disp(z)

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

View Full Document
Rutgers University SOE 14:440:127 Lecture 6 Find the max (and location) in a vector maxvalue = -inf; location = -1; for x = 1:length(V) if(V(x)>maxvalue) maxvalue = V(x); location = x; end end disp(maxvalue) disp(location)
Rutgers University SOE 14:440:127 Lecture 6 Plan of attack to find all locations of max Go through each element of the vector, starting at the beginning Keep a running tab of the maximum value we’ve seen When you find other locations equal to that max value, add that location to the end of a vector full of locations But, when you see a value that’s greater than our current max, save that new maximum, erase the old locations vector, and start a new one with that new location

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

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

{[ snackBarMessage ]}

### Page1 / 30

14-440-127 Lecture 6 Presentation - 14:440:127 Introduction...

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

View Full Document
Ask a homework question - tutors are online