lecture08

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

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

View Full Document Right Arrow Icon
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
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, 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
Background image of page 2
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
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, f11 4 Lecture 08 Command window Command window Read Read circleArea circleArea (3) (3) circleArea circleArea 3
Background image of page 4
CS107, Prof. Steinberg, f11 5 Lecture 08 Command window Command window circleArea circleArea 3 2 8.2743 Eval Eval
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, f11 6 Lecture 08 Command window Command window Print Print ans ans =2 =2 8.2743 2 8.2743
Background image of page 6
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
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, 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
Background image of page 8
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
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, 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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 47

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

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

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