Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer.

Slides:



Advertisements
Similar presentations
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Advertisements

情報基礎 B Lecture 5 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
3-2 What are relational operators and logical values? How to use the input and disp functions. Learn to use if, if-else and else-if conditional statements.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Computer Science in Practice This course is an introduction to problems (and solutions) that arise in applied fields of computer science such as machine.
ENGG 1801 Engineering Computing MATLAB Lecture 2: Background for Week 4 Tutorial Simple Programming in MATLAB.
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
Branches and Loops Selim Aksoy Bilkent University Department of Computer Engineering
Computer Science in Practice This course is an introduction to problems (and solutions) that arise in applied fields of computer science such as machine.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Copyright © Cengage Learning. All rights reserved. 7.6 The Inverse of a Square Matrix.
1.7 – Linear Inequalities and Compound Inequalities
Complex numbers 1.5 True or false: All numbers are Complex numbers.
Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Selection Programming EE 100. Outline introduction Relational and Logical Operators Flow Control Loops Update Processes.
CSE123 Lecture 3 Different types of Variables Logical operators, Conditional Statements and If Blocks.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Problem Solving with Decisions
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CMPS 1371 Introduction to Computing for Engineers CONDITIONAL STATEMENTS.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Computer Science 111 Fundamentals of Programming I Making Choices with if Statements.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (4): Control Flow (Chapter 2)
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
Chapter 4 Controlling Execution CSE Objectives Evaluate logical expressions –Boolean –Relational Change the flow of execution –Diagrams (e.g.,
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Thinking Mathematically
CS1109 L AB 3 July 3rd. R OAD M AP Homework submission Review How to use function and scripts While-end Finish last exercise Lab 2 Challenge questions.
CSE123 Lecture 3 Files and File ManagementScripts.
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.
Chapter 8: MuPAD Programming I Conditional Control and Loops MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
Digital Image Processing Introduction to M-function Programming.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
CSE 2813 Discrete Structures Solving Recurrence Relations Section 6.2.
3.4 Solving Equations with Variables on Both Sides Objective: Solve equations that have variables on both sides.
Conditional Logic in MATLAB By Bruce Raine. How to do a basic IF – END structure in MATLAB if MATLAB Commands end i.e. do the MATLAB commands if the conditional.
Solving Linear Equations and Inequalities Chapter 2.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TestScore < 80 testScore * 2 >= < w / (h * h) x + y != 2 * (a + b) 2 * Math.PI * radius
Notions & Notations - 1ICOM 4075 (Fall 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Fall 2010 ICOM.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Control Statements in Matlab
Sequence, Selection, Iteration The IF Statement
Chapter 4 MATLAB Programming
A computer program is a sequence of computer commands.
Conditional Statements
Control Structure Senior Lecturer
Summary Two basic concepts: variables and assignments Basic types:
Chapter 5: Control Structure
Conditional Statements
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Recapitulation of Lecture 8
CS2011 Introduction to Programming I Selections (I)
Objectives: Graph (and write) inequalities on a number line.
Matlab Basics.
6.3 Using Elimination to Solve Systems
Algebra: Variables and Expressions
Calculate 81 ÷ 3 = 27 3 x 3 x 3 3 x 3 x 3 x 3 ÷ 3 = This could be written as
The boolean type and boolean operators
Presentation transcript:

Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer of Biostatistics Technological Institute of Patras, Department of Physiotherapy, Branch of Egion Programming in Matlab Basic Control Structures

SymbolMeaning ==Equal >Greater Than >=Greater or Equal <Less Than <=Less or Equal ~=Not Equal Vlachopoulos Georgios

SymbolMeaning &Logical AND (conjugation) |Logical OR (disjunction) ~Logical NOT (negation) Vlachopoulos Georgios

ABA & BA | B~ A~B False True FalseTrueFalseTrue False TrueFalse TrueFalseTrue False Vlachopoulos Georgios Priority : &  |  ~

 Selection Structures ◦ Simple Selection ◦ Composite Selection ◦ Nested Selection ◦ Multiple Selection  Iteration Structures Vlachopoulos Georgios

Simple Selection Vlachopoulos Georgios condition commands if condition commands end

Composite Selection Vlachopoulos Georgios Condition commands1 if condition commands1 else commands2 end commands2

Nested Selection Vlachopoulos Georgios if condition1 commands1 if condition 2 … else … end else if condition 3 … else … end

Multiple Selection Vlachopoulos Georgios if condition1 Commands1 elseif condition2 Commands2 elseif condition3 Commands3 …. elseif conditionN CommandsN else CommandsN+1 end Every multiple Selection can be written as nested

 Example 1  Create an m-file that receives from the user a value and calculates the absolute value without the use of the corresponding elementary function  Example 2  Create an m-file that receives from the user the coefficients of a first order linear equation and solves it. Vlachopoulos Georgios

 For  while Vlachopoulos Georgios Syntax for index=initial_value:final_value:step commands end Syntax While condition commands end

for i=1:100:1 disp (‘Your Name’) End i=1 while (i<=100) disp (‘Your Name’) i=i+1 end Vlachopoulos Georgios

 Exercise 1a: Create an m-file to calculate the sum: s=1+2+3+…  Exercise 1b: Convert the m-file to function that receives as argument the final value of the sum and calculates it.  Exercise 1c: Create an m-file to calculate the sum: s=1+2+3+… up to the value that the sum remains lower to  Exercise 2: Create an m-file to calculate the product: p=3*5*7*…*21  Exercise 4: Create an m-file to calculate the sum: s= …50 4 up to the value that the sum remains lower to Vlachopoulos Georgios

 Exercise 5: Create an m-file to calculate the sum: S= …  Exercise 6: Create an m-file to calculate the sum: s=3!-4!+5!-6!+7!-…+21!  Exercise 7: Create an m-file to calculate the sum: Vlachopoulos Georgios