lecture03 (1) - CS107: Computing for Math CS107: and...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
CS107, Prof. Steinberg, S10 Lecture 03 CS107: Computing for Math CS107: Computing for Math and Science and Science Lecture 03: Functions
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 Lecture 03 Matlab Matlab Matlab is: A programming language A library of programs An Interactive Development Environment (IDE)
Background image of page 2
CS107, Prof. Steinberg, S10 Lecture 03 Matlab as a Calculator Matlab as a Calculator You type an expression Matlab Reads what you typed Evaluates the expression and Prints the result
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 Lecture 03 Expressions Expressions Expressions contain Numbers 3 -24.15 6.022e23 Operators Infix, eg .* ./ + - 1+4 Prefix, eg mod sqrt sqrt( 4 ) Variables
Background image of page 4
CS107, Prof. Steinberg, S10 Lecture 03 Variables Variables A variable is a place in the computer to store a piece of data Has a name, e.g. age, year, area, … Has a value, which can be changed When a variable appears in an expression, it means the current value large 98 17 + large means 17 + 98
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 Lecture 03 Why use a variable? Why use a variable? To save and reuse a value instead of recomputing it totTaxRate .* salary1 totTaxRate .* salary2
Background image of page 6
CS107, Prof. Steinberg, S10 Lecture 03 Why use a variable? Why use a variable? To keep track of current state in a sequential calculation Eg cube root of 5 x =5 x = x - (x.^3-5)/(2.*x.^2); x = x - (x.^3-5)/(2.*x.^2); x = x - (x.^3-5)/(2.*x.^2);
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 Lecture 03 Matlab Programs Matlab Programs A Matlab program is made up of statements One per line One kind of statement is the Assignment statement
Background image of page 8
CS107, Prof. Steinberg, S10 Lecture 03 Assignment statement Assignment statement Purpose: store a piece of data in a variable Form: variableName = expression Meaning: evaluate expression , store resulting value in variable with name variableName , print the value With ; at end do not print
Background image of page 9

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 1 Lecture 03 Beware the Mathomorphism Beware the Mathomorphism An assignment statement is not an equation An assignment statement says: Compute the value of this expression Store that value in this variable Nothing more, nothing less
Background image of page 10
CS107, Prof. Steinberg, S10 1 Lecture 03 Grammatical Structure Grammatical Structure An assignment statement has parts cost = nonTaxable + taxable .* 1.065 Variable name Expression
Background image of page 11

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

View Full DocumentRight Arrow Icon
CS107, Prof. Steinberg, S10 1
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/10/2011 for the course COMPUTER S 107 taught by Professor Imielinizki during the Spring '11 term at Rutgers.

Page1 / 49

lecture03 (1) - CS107: Computing for Math CS107: and...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online