{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture+03+Presentation

# Lecture+03+Presentation - 14:440 127 Introduction to...

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

14:440: 127 Introduction to Computers for Engineers Lecture 3 Lecturer: Brenda Cortez Recitation Instructors: Yun, Bo, Karthik, Muhammad 1

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

View Full Document
Rutgers School of Engineering 14:440:127 Announcements HW01 - DUE WED @ 7PM PROJ01 - DUE MON @ 7PM Mathworks giving MatLab Seminar October 5th here on Busch!!! Sign up if you are interested and are planning to attend! http://www.mathworks.com/company/events/seminars/seminar51569.html I will NOT hold OfFce Hours on TUESDAYS anymore Please be respectful of other people in the ofFce and knock before you come in (if I have written on the dry erase board “Brenda is here.”) PROJ HELP - ±RIDAY from 5PM - 10PM in DSV (break in between) EXAM 1 - Starts on September 30th (Written/Computer based) SAMPLE EXAM - will be posted Monday night 2
Rutgers School of Engineering 14:440:127 Last Lecture Class Reviewed Lecture01 Lecture02 Built-In Functions Conditional Structures: Switch/Case Element-wise Matrix Math Lets quickly recap! 3

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

View Full Document
Rutgers School of Engineering 14:440:127 Built-in Functions Problem 1: Suppose we have, A = [ 6 3 8 2 1 ]; Now we want to know the LOCATION of elements that meet some criteria. For example, what if we want to know where A>5 ? locations = ±nd (A>5) output: locations = [1 3] Problem 2: Now, pretend we have a matrix M and suppose we want to add together all elements greater than 100. sum (M( M>100 )) locations of M>100 Problem 3: Now, lets ±nd the biggest number between 130 and 150 max (M( )) addressing M using those locations Then sum 4
Rutgers School of Engineering 14:440:127 Built-in Functions: Be creative Problem 1: Sum the primes from 103 to 1003 sum ( primes (1003) - sum ( primes (102)) % 102 because when Fnding the prime numbers, 103 has to be included in the % sum, and if you use 103, you will be subtracting 103, instead of summing it. Problem 2: Now, create a vector V of the primes from 103 to 1003 5 will Fnd all prime numbers up to 1003 now, we Fnd those that are >=103 in vector a a = primes (1003); % Here's another solution a = primes (1003); V = a ( ( length ( primes (102) ) +1): end ) ; V = a(a>=103); ±ind primes up to 102, Fnd it ʼ s length, and add 1 to account for 103 address vector a from that length to the end % a>=103 returns a vector with 0s or 1s

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

View Full Document
Rutgers School of Engineering 14:440:127 Switch Case & More On input switch VARIABLENAME case OPTION1 STATEMENTS case OPTION2 STATEMENTS otherwise STATEMENTS end 6 BUT! 1. How many cases do we have? TWO - men case, women case 2. Write the script MorF = input( ʻ Enter gender - Female(F) or Male(M): ʼ , ʻ s ʼ ) switch MorF case ʻ F ʼ STATEMENTS case ʻ M ʼ STATEMENTS otherwise disp( ʻ You must enter F for Female or M for Male. ʼ ) end Problem 1: There is a ±ctional club call RU Disco that allows ladies to enter free before midnight and thereafter at \$10, while the men have to pay \$15 at any time. Using a switch/case
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 47

Lecture+03+Presentation - 14:440 127 Introduction to...

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

View Full Document
Ask a homework question - tutors are online