lecture08

lecture08 - CS107 Computing for Math and Science Lecture 08...

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

CS107, Prof. Steinberg, f11 1 Lecture 08 CS107: Computing for Math CS107: Computing for Math and Science and Science Lecture 08: while loops Loops and nesting

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

View Full Document
CS107, Prof. Steinberg, f11 2 Lecture 08 Midterm 1 Midterm 1 Tuesday, February 21 Pharmacy 111, 5:00 - 6:20 PM Normal lecture time and place Closed book, closed notes, bring ID On Sakai: Full rules Practice exam Topic list
CS107, Prof. Steinberg, f11 3 Lecture 08 Review: Command Window Review: Command Window Command window Command window Read Read Evaluate Evaluate Print Print circleArea circleArea (3) (3) ans ans =2 =2 8.2743

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

View Full Document
CS107, Prof. Steinberg, f11 4 Lecture 08 Command window Command window Read Read circleArea circleArea (3) (3) circleArea circleArea 3
CS107, Prof. Steinberg, f11 5 Lecture 08 Command window Command window circleArea circleArea 3 2 8.2743 Eval Eval

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

View Full Document
CS107, Prof. Steinberg, f11 6 Lecture 08 Command window Command window Print Print ans ans =2 =2 8.2743 2 8.2743
CS107, Prof. Steinberg, f11 7 Lecture 08 The command window The command window The evaluation may call functions which Use input to get more data from the user Use disp to print data on the screen During evaluation, data may get sent from one function to another As parameter value cos( 2*pi ) As returned result cos(2*pi) + 1 See sumxy.m, sumio.m

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

View Full Document
CS107, Prof. Steinberg, f11 8 Lecture 08 Structure of a for Structure of a for for j = 1 : 4 disp(j) end Sequence Loop Variable One or more statements
CS107, Prof. Steinberg, f11 9 Lecture 08 Meaning of a for Meaning of a for Set the variable to the first number in the sequence Do the statements Set the variable to the next number in the sequence Do the statements … etc … Set the variable to the last number in the sequence Do the statements

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

View Full Document
CS107, Prof. Steinberg, f11 10 Lecture 08 Example Example function countDown( start ) for j = start: -1 : 0 disp(j); end disp(‘blast off’) countDown( 3 ) 3 2 1 blast off
11 Lecture 08 Summary Variables Summary Variables Goal: add the numbers 1 through 4 for j = 1:4 ???? Problem: we have the numbers, but at

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 / 47

lecture08 - CS107 Computing for Math and Science Lecture 08...

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

View Full Document
Ask a homework question - tutors are online