Relational and Logical Operators. MATLAB Laboratory 10/07/10 Lecture. Chapter 7: Flow Control in Programs. Examples. Logical Operators.
|
|
- Emma Pope
- 5 years ago
- Views:
Transcription
1 Relational and Logical Operators MATLAB Laboratory 10/07/10 Lecture Chapter 7: Flow Control in Programs Both operators take on form expression1 OPERATOR expression2 and evaluate to either TRUE (1) or FALSE (0) Relational operators: Lisa A. Oberbroeckling Loyola University Maryland >> 1 < 2 1 < > <= <= == = >> 1 > 2 0 The relational operators produce matrices of 0s and 1s if one of the arguments is a matrix. L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 1 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 2 / 1 Logical Operators s &, && AND (eager version,short-circuit version), OR (eager version, short-circuit version) NOT xor Exclusive OR all TRUE if all elements of vector are nonzero any TRUE if any elements of vector are nonzero Eager version will evaluate both expressions no matter what. The Short-circuit versions are only good on scalars and will only evaluate the second expression if needed. Pros and cons to each version in complicated programs - search for Short-circuit evaluation on Wikipedia for examples. The eager version of AND, OR, and NOT logical operators produce matrices of 0s and 1s if one of the arguments is a matrix. >> x = [-1 1 1]; y = [1 2-3]; >> x>0 & y > >> x>0 y> >> xor(x>0,y>0) >> any(x>0) 1 >> all(x>0) 0 >> if x>0 && sin(1/x)<0.5 % one use of short-circuit L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 3 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 4 / 1
2 Order of Precedence Flow Control More functions in book! Precedence Operation 1 Parentheses 2 Exponents 3 Logical NOT 4 Multiplication/division 5 Addition/subtraction 6 Relational operators 7 Logical AND (&) 8 Logical OR ( ) 1 if- 2 if-- 3 if-if switch 5 for 6 while The first four are conditional statements The last two are loops L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 5 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 6 / 1 IF statement IF ELSE and IF ELSEIF... ELSE if b ~=0 && (a == 5 a==3) y=a/b; z=a+b; if x >= 0 absx = x; absx = -x;. L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 7 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 8 / 1
3 sgn.m function s = sgn(x) % SGN(X) computes the sign or signum of the number X % if x < 0 s = -1; if x > 0 s = 1; sgn2.m function s = sgn2(x) % SGN2(X) Computes the sign or signum of the number X. % First checks that X is a number. if length(x) ~= 1 error( Input of sgn2 function is not a number ) if x < 0 s = -1; if x > 0 s = 1; L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 9 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 10 / 1 Pseudocode and Testing SWITCH statement Pseudocode (from dictionary.com) a program code unrelated to the hardware of a particular computer and requiring conversion to the code used by the computer before the program can be used. Pseudocode is especially useful to plan out your program(s) on scratch paper before typing - what variables do you need? What conditional statements need to be done, and how? How to set up the loops, etc. Testing: try and think of easy accuracy checks, but also error checks. switch expression case value case value. otherwise switch mod(n,2) case 0 disp( n is even! ) case 1 disp( n is odd! ) otherwise disp( n is not an integer! ) This can be easier in some instances than an if-if- statement L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 11 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 12 / 1
4 FOR loop for indexvariable = a:i:b MATLAB command(s) indexvariable does not need to be declared before; it can be new (and probably should be new) a:i:b or a:b has the indexvariable start at a and at (or going no further than) b, with an increment of i. (remember, if the increment is left out, the increment is 1). indexvariable = vector also works (see forex2.m) There is no need to increment the indexvariable; that is automatically done geomseries.m function s = geomseries(r, n) % GEOMSERIES(N) computes the sum of the geometric sequence % of R from k=0 to N % for k=0:n s = s + r^k; GOOD FOR SERIES! L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 13 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 14 / 1 WHILE loop While PSEUDOCODE while something is true do something Statements are executed as long as expression is true. Nice commands: break and continue read about it (also can be used in FOR loops) Something must change so loop isn t infinite! Read Chapter 7 and the H-drive for more details, syntax and examples! whileex1a.m function y = whileex1a(n) % WHILEEX1A(N) adds the numbers from 1 to N % L Oberbroeckling y=0; k=1; while k <= n y = y+k; k = k+1; L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 15 / 1 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 16 / 1
5 Notes on Nesting Loops and conditional statements can be nested within themselves Keep organized by having nice spacing (USE TABS) nest1 nest2 nest3 L. Oberbroeckling (Loyola University) MATLAB 10/07/10 Lecture 17 / 1
MATLAB Laboratory 10/07/10 Lecture. Chapter 7: Flow Control in Programs
MATLAB Laboratory 10/07/10 Lecture Chapter 7: Flow Control in Programs Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu L. Oberbroeckling (Loyola University) MATLAB 10/07/10
More information7 Control Structures, Logical Statements
7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,
More informationChapter 7: Programming in MATLAB
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 7: Programming in MATLAB 1 7.1 Relational and Logical Operators == Equal to ~=
More informationC/C++ Programming for Engineers: Matlab Branches and Loops
C/C++ Programming for Engineers: Matlab Branches and Loops John T. Bell Department of Computer Science University of Illinois, Chicago Review What is the difference between a script and a function in Matlab?
More informationProgramming for Experimental Research. Flow Control
Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated
More informationfunction [s p] = sumprod (f, g)
Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:
More informationStarting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.
Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...
More informationENGR 1181 MATLAB 09: For Loops 2
ENGR 1181 MATLAB 09: For Loops Learning Objectives 1. Use more complex ways of setting the loop index. Construct nested loops in the following situations: a. For use with two dimensional arrays b. For
More informationRelational and Logical Operators
Relational and Logical Operators Relational Operators Relational operators are used to represent conditions (such as space 0 in the water tank example) Result of the condition is either true or false In
More informationProgramming in MATLAB
2. Scripts, Input/Output and if Faculty of mathematics, physics and informatics Comenius University in Bratislava October 7th, 2015 Scripts Scripts script is basically just a sequence of commands the same
More informationCOGS 119/219 MATLAB for Experimental Research. Fall 2016 Week 1 Built-in array functions, Data types.m files, begin Flow Control
COGS 119/219 MATLAB for Experimental Research Fall 2016 Week 1 Built-in array functions, Data types.m files, begin Flow Control .m files We can write the MATLAB commands that we type at the command window
More informationMATLIP: MATLAB-Like Language for Image Processing
COMS W4115: Programming Languages and Translators MATLIP: MATLAB-Like Language for Image Processing Language Reference Manual Pin-Chin Huang (ph2249@columbia.edu) Shariar Zaber Kazi (szk2103@columbia.edu)
More informationConstraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial
1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the
More informationBoolean Logic & Branching Lab Conditional Tests
I. Boolean (Logical) Operations Boolean Logic & Branching Lab Conditional Tests 1. Review of Binary logic Three basic logical operations are commonly used in binary logic: and, or, and not. Table 1 lists
More informationIntroduction to MATLAB
Introduction to MATLAB Dr./ Ahmed Nagib Mechanical Engineering department, Alexandria university, Egypt Spring 2017 Chapter 4 Decision making and looping functions (If, for and while functions) 4-1 Flowcharts
More informationControl Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28
Control Structures Dr. Mihail March 1, 2015 (Dr. Mihail) Control March 1, 2015 1 / 28 Overview So far in this course, MATLAB programs consisted of a ordered sequence of mathematical operations, functions,
More informationPractice Reading for Loops
ME 350 Lab Exercise 3 Fall 07 for loops, fprintf, if constructs Practice Reading for Loops For each of the following code snippets, fill out the table to the right with the values displayed when the code
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #16 Loops: Matrix Using Nested for Loop In this section, we will use the, for loop to code of the matrix problem.
More informationAPPM 2460: Week Three For, While and If s
APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop
More informationRepetition Structures
Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements
More informationCondition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.
Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes
More informationMATLAB Operators, control flow and scripting. Edited by Péter Vass
MATLAB Operators, control flow and scripting Edited by Péter Vass Operators An operator is a symbol which is used for specifying some kind of operation to be executed. An operator is always the member
More informationStructure Array 1 / 50
Structure Array A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. Access data in a structure using dot notation of
More informationSelection Statements. Chapter 4. Copyright 2013 Elsevier Inc. All rights reserved 1
Selection Statements Chapter 4 Copyright 2013 Elsevier Inc. All rights reserved 1 Recall Relational Expressions The relational operators in MATLAB are: > greater than < less than >= greater than or equals
More informationCS 221 Lecture. Tuesday, 11 October 2011
CS 221 Lecture Tuesday, 11 October 2011 "Computers in the future may weigh no more than 1.5 tons." - Popular Mechanics, forecasting the relentless march of science, 1949. Today s Topics 1. Announcements
More informationRepetition Structures Chapter 9
Sum of the terms Repetition Structures Chapter 9 1 Value of the Alternating Harmonic Series 0.9 0.8 0.7 0.6 0.5 10 0 10 1 10 2 10 3 Number of terms Objectives After studying this chapter you should be
More informationControl Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003
Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an
More informationMAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB
MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs
More informationIntroduction. C provides two styles of flow control:
Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if
More informationDr. Khaled Al-Qawasmi
Al-Isra University Faculty of Information Technology Department of CS Programming Mathematics using MATLAB 605351 Dr. Khaled Al-Qawasmi ١ Dr. Kahled Al-Qawasmi 2010-2011 Chapter 3 Selection Statements
More informationFlow Control. Spring Flow Control Spring / 26
Flow Control Spring 2019 Flow Control Spring 2019 1 / 26 Relational Expressions Conditions in if statements use expressions that are conceptually either true or false. These expressions are called relational
More informationFiles and File Management Scripts Logical Operations Conditional Statements
Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Matlab provides a group of commands to manage user files pwd: Print working directory displays the
More informationOrdinary Differential Equation Solver Language (ODESL) Reference Manual
Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE
More informationRELATIONAL AND LOGICAL OPERATORS
Contents RELATIONAL AND LOGICAL OPERATORS... Relational Operators... Logical Operators... Using Relational and Logical Operators with Scalars... 2 Using Relational Operators with Numerical Arrays... 5
More information21-Loops Part 2 text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie
21-Loops Part 2 text: Chapter 6.4-6.6 ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie While Loop Infinite Loops Break and Continue Overview Dr. Henry Louie 2 WHILE Loop Used to
More informationMATLAB TUTORIAL WORKSHEET
MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent
More informationMini-Matlab Lesson 5: Functions and Loops
Mini-Matlab Lesson 5: Functions and Loops Writing Functions and Scripts Contents Relational and logical operators IF loops FOR loops WHILE loops Scripts and functions Defining and using functions Anonymous
More informationSelection Statements
Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators, logical operators, truth
More informationMcTutorial: A MATLAB Tutorial
McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB
More informationCS302: Self Check Quiz 2
CS302: Self Check Quiz 2 name: Part I True or False For these questions, is the statement true or false? Assume the statements are about the Java programming language. 1.) The result of an expression with
More informationComputer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering
Computer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering 1 Introduction A computer program is a sequence of computer
More informationLecture 3 MATLAB programming (1) Dr.Qi Ying
Lecture 3 MATLAB programming (1) Dr.Qi Ying Objectives Data types Logical operators/functions Branching Debugging of a program Data types in MATLAB Basic: Numeric (integer, floating-point, complex) Logical:
More informationThe Many Lessons in Fractals
The Many Lessons in Fractals Lisa Oberbroeckling loberbro@loyola.edu MAA Mathfest Washington, D.C. L. Oberbroeckling (Loyola U MD) Fractals Mathfest, 05 Aug 2015 1 / 15 Course Programming in Mathematics
More informationSelections. Zheng-Liang Lu 91 / 120
Selections ˆ Selection enables us to write programs that make decisions on. ˆ Selection structures contain one or more of the if, else, and elseif statements. ˆ The end statement denotes the end of selection
More informationChapter 3: Programming with MATLAB
Chapter 3: Programming with MATLAB Choi Hae Jin Chapter Objectives q Learning how to create well-documented M-files in the edit window and invoke them from the command window. q Understanding how script
More informationIntroduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices
Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are
More informationEL2310 Scientific Programming
Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last
More informationIntroduction to Engineering gii
25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.
More informationCSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions
1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions
More informationFlow Control. Statements We Will Use in Flow Control. Statements We Will Use in Flow Control Relational Operators
Flow Control We can control when how and the number of times calculations are made based on values of input data and/or data calculations in the program. Statements We Will Use in Flow Control for loops
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationProblem One: A Quick Algebra Review
CS103A Winter 2019 Solutions for Week One Handout 01S Problem One: A Quick Algebra Review In the first week of CS103, we'll be doing a few proofs that will require some algebraic manipulations and reasoning
More informationRelational and Logical Statements
Relational and Logical Statements Relational Operators in MATLAB A operator B A and B can be: Variables or constants or expressions to compute Scalars or arrays Numeric or string Operators: > (greater
More informationChapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 4 Procedural Abstraction and Functions That Return a Value 1 Overview 4.1 Top-Down Design 4.2 Predefined Functions 4.3 Programmer-Defined Functions 4.4 Procedural Abstraction 4.5 Local Variables
More informationMATLAB provides several built-in statements that allow for conditional behavior if/elseif/else switch menu
Chapter 3 What we have done so far: Scripts/Functions have executed all commands in order, not matter what What we often need: A piece of code that executes a series of commands, if and only if some condition
More informationCS227-Scientific Computing. Lecture 3-MATLAB Programming
CS227-Scientific Computing Lecture 3-MATLAB Programming Contents of this lecture Relational operators The MATLAB while Function M-files vs script M-files The MATLAB for Logical Operators The MATLAB if
More informationEL2310 Scientific Programming
(pronobis@kth.se) Overview Overview Wrap Up More on Scripts and Functions Basic Programming Lecture 2 Lecture 3 Lecture 4 Wrap Up Last time Loading data from file: load( filename ) Graphical input and
More informationREPETITIVE EXECUTION: LOOPS
Contents REPETITIVE EXECUTION: LOOPS... 1 for Loops... 1 while Loops... 6 The break and continue Commands... 8 Nested Loops... 10 Distinguishing Characteristics of for and while Loops Things to Remember...
More informationRelational & Logical Operators, Selection Statements
Relational & Logical Operators, Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators,
More informationLecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan
Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful
More informationChapter 4. Flow of Control
Chapter 4. Flow of Control Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr Sequential flow of control
More informationDigital Image Processing
Digital Image Processing Introduction to MATLAB Hanan Hardan 1 Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The name MATLAB is an interactive system
More informationMAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB
MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs in MATLAB NOTE: For your
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationMATLAB Laboratory 09/23/10 Lecture. Chapters 5 and 9: Plotting
MATLAB Laboratory 09/23/10 Lecture Chapters 5 and 9: Plotting Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu L. Oberbroeckling (Loyola University) MATLAB 09/23/10 Lecture
More informationCSE200 Lecture 6: RECURSION
Table of Contents Review of functions (using factorial example)... 1 Recursion... 1 Step by step run through of recursive factorial... 2 Recursion vs. iteration (for and while loops)... 3 Helper functions:...
More informationDr. Iyad Jafar. Adapted from the publisher slides
Computer Applications Lab Lab 5 Programming in Matlab Chapter 4 Sections 1,2,3,4 Dr. Iyad Jafar Adapted from the publisher slides Outline Program design and development Relational operators and logical
More informationYOLOP Language Reference Manual
YOLOP Language Reference Manual Sasha McIntosh, Jonathan Liu & Lisa Li sam2270, jl3516 and ll2768 1. Introduction YOLOP (Your Octothorpean Language for Optical Processing) is an image manipulation language
More informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
More informationRelational & Logical Operators
Relational & Logical Operators ELEC 206 Prof. Siripong Potisuk 1 Objectives Learn how to change the flow of execution of a MATLAB program through some kind of a decision-making process within that program
More informationIntroduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.
Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations
More informationRelational Expressions. Boolean Expressions. Boolean Expressions. ICOM 4036 Programming Languages. Boolean Expressions
ICOM 4036 Programming Languages Ch7. Expressions & Assignment Statements Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions Short-Circuit Evaluation Assignment
More informationChapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationThese are notes for the third lecture; if statements and loops.
These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern
More informationIntroduction to Matlab. By: Hossein Hamooni Fall 2014
Introduction to Matlab By: Hossein Hamooni Fall 2014 Why Matlab? Data analytics task Large data processing Multi-platform, Multi Format data importing Graphing Modeling Lots of built-in functions for rapid
More informationProgramming in MATLAB Part 2
Programming in MATLAB Part 2 A computer program is a sequence of computer commands. In a simple program the commands are executed one after the other in the order they are typed. MATLAB provides several
More informationIntroduction to C Programming
1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print
More informationMA 511: Computer Programming Lecture 3: Partha Sarathi Mandal
MA 511: Computer Programming Lecture 3: http://www.iitg.ernet.in/psm/indexing_ma511/y10/index.html Partha Sarathi Mandal psm@iitg.ernet.ac.in Dept. of Mathematics, IIT Guwahati Semester 1, 2010-11 Last
More informationREPETITION CONTROL STRUCTURE LOGO
CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of
More informationAn Introduction to MATLAB
An Introduction to MATLAB Day 1 Simon Mitchell Simon.Mitchell@ucla.edu High level language Programing language and development environment Built-in development tools Numerical manipulation Plotting of
More informationPhysics 326 Matlab Primer. A Matlab Primer. See the file basics.m, which contains much of the following.
A Matlab Primer Here is how the Matlab workspace looks on my laptop, which is running Windows Vista. Note the presence of the Command Window in the center of the display. You ll want to create a folder
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationComputational Physics - Fortran February 1997
Fortran 90 Decision Structures IF commands 3 main possibilities IF (logical expression) IF (logical expression) THEN IF (logical expression) THEN IF (logical expression) THEN expression TRUE expression
More information3.4. FOR-LOOPS 65. for <v a r i a b l e > in < sequence >:
3.4. FOR-LOOPS 65 3.4 For-loops In the previous section we looked at while-loops, Python s basic looping structure. There is a second loop construct in Python called a for-loop. This is more specialized.
More informationLECTURE 0: Introduction and Background
1 LECTURE 0: Introduction and Background September 10, 2012 1 Computational science The role of computational science has become increasingly significant during the last few decades. It has become the
More informationSoftware Development Techniques. December Sample Exam Marking Scheme
Software Development Techniques December 2015 Sample Exam Marking Scheme This marking scheme has been prepared as a guide only to markers. This is not a set of model answers, or the exclusive answers to
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationNumerical Methods Lecture 1
Numerical Methods Lecture 1 Basics of MATLAB by Pavel Ludvík The recommended textbook: Numerical Methods Lecture 1 by Pavel Ludvík 2 / 30 The recommended textbook: Title: Numerical methods with worked
More informationWhat is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment
What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful
More informationLanguage Reference Manual
ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents
More informationCEMTool Tutorial. Control statements
CEMTool Tutorial Control statements Overview This tutorial is part of the CEMWARE series. Each tutorial in this series will teach you a specific topic of common applications by explaining theoretical concepts
More informationMatlab? Chapter 3-4 Matlab and IPT Basics. Working Environment. Matlab Demo. Array. Data Type. MATLAB Desktop:
Matlab? Lecture Slides ME 4060 Machine Vision and Vision-based Control Chapter 3-4 Matlab and IPT Basics By Dr. Debao Zhou 1 MATric LABoratory data analysis, prototype and visualization Matrix operation
More informationWriting Program in C Expressions and Control Structures (Selection Statements and Loops)
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationVariables and Assignments
Variables and Assignments ˆ A variable is used to keep a value or values. ˆ A box which contains something. ˆ In most languages, a statement looks like var = expression, where var is a variable and expression
More informationPart I Part 1 Expressions
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationLecture 11: Logical Functions & Selection Structures CMPSC 200 Programming for Engineers with MATLAB
Lecture 11: Logical Functions & Selection Structures CMPSC 2 Programming for Engineers with MATLAB Brad Sottile Fall 214 Slide 2 of 3 Midterm 1 Details You must bring your PSU student ID card Scantron
More informationControl Statements. Objectives. ELEC 206 Prof. Siripong Potisuk
Control Statements ELEC 206 Prof. Siripong Potisuk 1 Objectives Learn how to change the flow of execution of a MATLAB program through some kind of a decision-making process within that program The program
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationSCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017
SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More information