Lecture 02 Presentation

# Lecture 02 Presentation - 14:440:127 Introduction to...

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

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document

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.

Unformatted text preview: 14:440:127 Introduction to Computers for Engineers Lecture 2 LEASE TAKE LECTURE 2 NOTES PLEASE TAKE LECTURE 2 NOTES AS YOU ENTER THE ROOM! Lecturer: Blase E. Ur Recitation Instructor: Bocheng ‘Bo’ Jin Recitation Instructor: Cyrus Gerami Recitation Instructor: Vishnu Vijayakumar Recitation Instructor: Wen Yueh 14:440:127 Lecture 2 Variables • Contain values • Start with a letter, continue with letters/numbers/underscore • Case Sensitive (x is different than X) • File Names-- ALSO DON'T INCLUDE SPACES • Semicolon / disp • whos, clear, clc 14:440:127 Lecture 2 Switching Variables • Doesn’t work – A = 15 – B = 20 – A=B; – B=A; • Why? – A=15 – A=15, B=20 – A=20, B=20 – A=20, B=20 14:440:127 Lecture 2 Switching Variables • DOES work – A = 15 – B = 20 – Temp=A; – A=B; =Temp; – B=Temp; • Why? – A=15 – A=15, B=20 – A=15, B=20, Temp=15 – A=20, B=20, Temp=15 – A=20, B=15, Temp=15 14:440:127 Lecture 2 Adding One • X = X + 1; 14:440:127 Lecture 2 Data Types • Integers • Floating Point (double) • Vectors, Matrices, Arrays • Character Arrays, Strings tructs, Cell Arrays • Structs, Cell Arrays • Inf b Infinity • NaN: 0/0 • 0.999999999 14:440:127 Lecture 2 Built-In Functions • FunctionName(input1, input2, input3,…) sqrt(5) % square root of 5 nthroot(27,3) %cube(3) root of 27 sin(pi) % sine of pi radians cos(pi/2) % cosine of pi/2 asin(1) % arcsine of 1 sind(75) % sine of 75 degrees log(5) % natural logarithm (base e) of 5 log10(5) % logarithm (base 10) of 5 exp(5) % e^5 14:440:127 Lecture 2 Built-In Functions rem(15,2) % remainder of 15/2 mod(15,2) % similar to rem % but different for different signs sign(x) % 1 for x>0, 0 for x=0, -1 for x<0 factor(15) % returns the prime factors of 15 gcd(15,20) % the greatest common divisor lcm(3,7) % least common multiple factorial(15) % 15! primes(100) % lists all primes <= 100 isprime(101) % 1 (true) or 0 (false) 101 is prime 14:440:127 Lecture 2 Round Functions round(5.3) % round 5.3 (.5 or greater rounds up) fix(5.3) % round towards 0 floor(5.3) % round towards -inf ceil(5.3) % round towards +inf round(5.3) % ans = 5 fix(5.3) % ans = 5 floor(5.3) % ans = 5 ceil(5.3) % ans = 6 round(5.6) % ans = 6 fix(5.6) % ans = 5 floor(5.6) % ans = 5 ceil(5.6) % ans = 6 round(-5.6) % ans = -6 fix(-5.6) % ans = -5 floor(-5.6) % ans = -6 ceil(-5.6) % ans = -5 14:440:127 Lecture 2 Help, Comments • Help • Just type “help functionname” • Comments you type a %, anything to the right is considered a comment and • If you type a %, anything to the right is considered a comment and is ignored • Why use comments? Make notes to yourself about how things work • Why use comments? Why use comments?...
View Full Document

## This note was uploaded on 01/11/2010 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

### Page1 / 41

Lecture 02 Presentation - 14:440:127 Introduction to...

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

View Full Document
Ask a homework question - tutors are online