This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 14:440:127 Introduction to Computers for Engineers Lecture 6 LEASE TAKE LECTURE 6 NOTES PLEASE TAKE LECTURE 6 NOTES AS YOU ENTER THE ROOM! Lecturer: Blase E. Ur Recitation Instructor: Bo Jin Recitation Instructor: Cyrus Gerami Recitation Instructor: Vishnu Vijayakumar Recitation Instructor: Wen Yueh 14:440:127 Lecture 6 polyfit polyfit(x,y,degree) x = [1 2 3 4 5]; y = [9 22 41 66 97]; Coeffs = polyfit(x,y,2) Rutgers University BuffaLOL %%% We find that >>coeffs = 3.0000 4.000 2.000 %%% The curve it found was y=3x 2 + 4x + 2 14:440:127 Lecture 6 What if there’s data and don’t know what to do? Plot it a bunch of ways (plot, semilogx, semilogy, loglog) and look for something recognizable. Rutgers University BuffaLOL 14:440:127 Lecture 6 Semilogx y = K*x 2 + C Display the x axis as powers of 10equivalent to taking the log of the x points Use semilogx(x,y) instead of plot(x,y) Logarithmic Data: y = K * log(x) + C Rutgers University BuffaLOL y = K * log(x) + C 14:440:127 Lecture 6 Semilogy y 2 = K*x + C 2 Display the y axis as powers of 10equivalent to taking the log of the y points Use semilogy(x,y) instead of plot(x,y) Exponential Data: = C*e kx Rutgers University BuffaLOL y = C*e 14:440:127 Lecture 6 Loglog y 2 = K*x 2 + C 2 Display the x and y axis as powers of 10equivalent to taking the log of the x and y points Use loglog (x,y) instead of plot(x,y) Power Function Data: = C*x k Rutgers University BuffaLOL y = C*x 14:440:127 Lecture 6 Semilogx is Straight Logarithmic Data: y = K * log(x) + C semilogx(x,y) % straightish coeffs = polyfit(log(x),y,1) % y = K*x 2 + C K = coeffs(1) Rutgers University BuffaLOL K = coeffs(1) C = coeffs(2) 14:440:127 Lecture 6 Semilogy is straight Exponential Data: y = C*e kx semilogy(x,y) % straightish coeffs = polyfit(x,log(y),1) % y 2 = K*x + C 2 = coeffs(1) Rutgers University BuffaLOL K = coeffs(1) C = exp(coeffs(2)) 14:440:127 Lecture 6 Loglog Power Function Data: y = C*x k loglog(x,y) % straightish coeffs = polyfit(log(x),log(y),1) % y 2 = K*x 2 + C 2 = coeffs(1) Rutgers University BuffaLOL K = coeffs(1) C = exp(coeffs(2)) 14:440:127 Lecture 6 Pseudorandom numbers rand(m,n) rand(s) Rutgers University BuffaLOL All values are in the unit interval [0,1] 14:440:127 Lecture 6 Pseudorandom numbers Interval [0,b] Rutgers University BuffaLOL 14:440:127 Lecture 6 Pseudorandom numbers Interval [a,b] Rutgers University BuffaLOL 14:440:127 Lecture 6 Pseudorandom numbers Integers [1,x] Rutgers University BuffaLOL 14:440:127 Lecture 6 randperm randperm(15) Rutgers University BuffaLOL 14:440:127 Lecture 6 Why PSEUDOrandom? Rutgers University BuffaLOL • rand(‘seed’,x) • rand(‘state’,x) • Linear Congruential Generator= x n+1 = a*x n + c (mod n) BAD! 14:440:127 Lecture 6 Announcements • Problem Set 1 due (for Tuesday lecture)… or was due (Wednesday lecture) • Project 2 (Sudoku) imminent ill feature the greatest ever contest....
View
Full Document
 Fall '09
 blase
 Rutgers University, Rutgers University BuffaLOL

Click to edit the document details