Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

Slides:



Advertisements
Similar presentations
Programming Methodology (1). Iteration Learning objectives explain the term iteration; repeat a section of code with a for loop; repeat a section of.
Advertisements

CS 4 Intro to Programming using Visual Basic Do Loops Patchrawat Uthaisombut University of Pittsburgh 1 based on lecture notes by D. Schneider.
Introducing DFA Formal Description Using Peer Instruction Cynthia Bailey Lee UCSD 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
Lecture Notes 3 Loops (Repetition)
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR Dr. Cynthia Lee - UCSD - Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
CMPS 1371 Introduction to Computing for Engineers
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Visual Basic.NET BASICS Lesson 10 Do Loops. 2 Objectives Explain what a loop is. Use the Do While and Do Until loops. Use the InputBox function. Use the.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 5 Looping.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
V Avon High School Tech Club Agenda Old Business –Delete Files New Business –Week 16 Topics: Intro to HTML/CSS –Questions? Tech Club Forums.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
LabVIEW Program and Data Flow Review LabVIEW Robotics Fundamentals.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
Lecture 8: Choosing the Correct Loop. do … while Repetition Statement Similar to the while statement Condition for repetition only tested after the body.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
1 Flow of control Sequential Executing instructions one by one, in exact order given Selection Choosing to execute a particular set of statements depending.
CPS120 Introduction to Computer Programming The Programming Process.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Tutorial: Reduction from A TM Proofs Dr. Cynthia Lee CSE 105, UCSD Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee,
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
Repetition and Iteration ANSI-C. Repetition We need a control instruction to allows us to execute an statement or a set of statements as many times as.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Chapter 8: MuPAD Programming I Conditional Control and Loops MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Repetition Structures.
CSC 1010 Programming for All Lecture 4 Loops Some material based on material from Marty Stepp, Instructor, University of Washington.
Controlling Program Flow with Looping Structures
Tutorial 9 Iteration. Reminder Assignment 8 is due Wednesday.
COMP Loop Statements Yi Hong May 21, 2015.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
Linear Search Linear Search is a fundamental search algorithm. Linear search, also known as sequential search, is a process that checks every element in.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chapter 6 Controlling Program Flow with Looping Structures.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Introduction to Programming in MATLAB
Chapter 3: Decisions and Loops
PROGRAM CONTROL STRUCTURE
Introduction to Programming in MATLAB
CS1371 Introduction to Computing for Engineers
Lecture 4 - Loops UniMAP EKT120 Sem 1 08/09.
Introducing Do While & Do Until Loops & Repetition Statements
Scrolling text repeating until end of slide.
CPS120: Introduction to Computer Science
Alternate Version of STARTING OUT WITH C++ 4th Edition
Binary Search A binary search algorithm finds the position of a specified value within a sorted array. Binary search is a technique for searching an ordered.
Control Structures Part 1
Introduction to Repetition Structures
DO NOT OPEN YOUR BINDER UNTIL INSTRUCTED
A LESSON IN LOOPING What is a loop?
Introduction to Programming in MATLAB
Introduction to Computer Science
Introduction to Programming in MATLAB
Little Man Computer (continued).
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Presentation transcript:

Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org 1

CONTROL FLOW Choosing the most appropriate 2

Control Flow I want to write a function that iterates over the pixels of a matrix to see if there is one that is pure green ( ). If there is, I will return true, otherwise I will return false. Which type of control flow should I use? a)if/elseif/else b)switch/case c)for loop d)while loop e)Other/none/more than one 3

Control Flow I want to write a function that reads input that the user types, while the user types it (we haven’t learned this yet, but it is very easy to do—just a call to a function similar to display, but it reads in addition to writing). We call the read function once for each line of text read, and we want to keep calling the read function repeatedly until we detect that the user typed ‘STOP’. Which type of control flow should I use? a)if/elseif/else b)switch/case c)for loop d)while loop e)Other/none/more than one 4

Control Flow My BakeTime function takes as input one of five different values (‘pizza’, ‘casserole’, ‘bread’, ‘chicken’, ‘cupcakes’). Depending on which it is, we will return a different number of minutes that item should be baked in an oven. Which type of control flow should I use? a)if/elseif/else b)switch/case c)for loop d)while loop e)Other/none/more than one 5