1 / 5

Introduction to Programming in MATLAB

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  www.peerinstruction4cs.org . Choosing the most appropriate.

temima
Télécharger la présentation

Introduction to Programming in MATLAB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 www.peerinstruction4cs.org.

  2. Choosing the most appropriate Control Flow

  3. 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 (0 255 0). If there is, I will return true, otherwise I will return false.Which type of control flow should I use? • if/elseif/else • switch/case • for loop • while loop • Other/none/more than one

  4. 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? • if/elseif/else • switch/case • for loop • while loop • Other/none/more than one

  5. 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? • if/elseif/else • switch/case • for loop • while loop • Other/none/more than one

More Related