General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.

Slides:



Advertisements
Similar presentations
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Advertisements

Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Week 7 - Programming I Relational Operators A > B Logical Operators A | B For Loops for n = 1:10 –commands end.
General Computer Science for Engineers CISC 106 Lecture 13 Roger Craig Computer and Information Sciences 3/13/2009.
General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
General Computer Science for Engineers CISC 106 Lecture 06 Roger Craig Computer and Information Sciences 2/23/2009.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 21P. 1Winter Quarter MATLAB: Structures.
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Selection Programming EE 100. Outline introduction Relational and Logical Operators Flow Control Loops Update Processes.
Conditional Control Flow By Muhammad Ahsan Qadar SACS Programming Fundamentals Workshop 1.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
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.
ENGR-25_Programming-3.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
1 Input / Output Input – reads/gets data for the program Output – the product, after processing Both can be: interactive I/O (while program is running)
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
EGR 115 Introduction to Computing for Engineers Formatted File Input / Output Wednesday 12 Nov 2014 EGR 115 Introduction to Computing for Engineers.
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.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Digital Image Processing Introduction to M-function Programming.
1 CS1371 Introduction to Computing for Engineers Control Statements 9/4/2003.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
Matlab Basic. MATLAB Product Family 2 3 Entering & Quitting MATLAB To enter MATLAB double click on the MATLAB icon. To Leave MATLAB Simply type quit.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
Language Find the latest version of this document at
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
An Introduction to Programming in Matlab Emily Blumenthal
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
Matlab Programming for Engineers
ECE 1304 Introduction to Electrical and Computer Engineering
Control Statements in Matlab
MATLAB: Structures and File I/O
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Use of Mathematics using Technology (Maltlab)
Introduction to MATLAB [Vectors and Matrices] Lab 2
Chapter2 Creating Arrays
INTRODUCTION TO MATLAB
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.
Matlab Basics.
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Announcements.
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009

Lecture Objectives If statements (nested) Logical Operators Matlab Output

IF Statements Nested if statements can be used when two things have to be true for a command to execute

IF Statements Using nested if statements if (x < 5) if ( x > 2) y = 500 else y = 300 end else y= 200 end

IF Statements Using nested if statements if (x < 5) if ( x > 2) y = 500 else y = 300 end else y= 200 end Using multiple conditions in one if statement if ( x 2) y = 500 else y = 200 end

Logical Operators - AND & && A & B A TF B TTF FFF

Logical Operators - OR | || A | B A TF B TTT FTF

Logical Operators - NOT ~ ~A TF FT

Numbers as True/False What do you think would happen here: if (5) disp(‘5 is a true value’); else disp(‘5 is a false value’); end

Numbers as True/False Group activity: evaluate the following as true or false for x=5:  x < 7 & 3 < x 2. ˜ (x / 2 > 1 & x < 0)  x ˜ = 5 & x + 2 > 6 | x > 5  x + x == 2 * x && ˜ x

Matlab Output ◦ How do we see information about what is going on in our program?

Matlab Output ◦ How do we see information about what is going on in our program? ◦ disp()

Matlab Output Formatted Output Example: ◦ “There are 5 widgets in inventory” ◦ fprintf(‘There are %d widgets in inventory’, widgets);

Matlab Output Formatted Output Example: ◦ “There are 5 widgets in inventory” ◦ fprintf(‘There are %d widgets in inventory’, widgets); %d acts as a place holder for widget variable at end of command and is known as a conversion character. Conversion characters specify the notation of the output. Note the variable widgets as the second argument.

Matlab Output Lets look at the syntax ◦ count = fprintf(fid, format, A,...) ◦ count – the number of bytes written ◦ fid – refers to opened file ◦ format – is a format string in between single quotes If fid is set to one or omitted the output goes to the screen.

Arrays

Arrays

Arrays Fundamental unit of data in MATLAB Collection of data into rows and columns (MATrix LABoratory) 1 dimensional, vector 2 dimensional, matrix 0 dimensional, scalar (a 1x1 array) Row vector, column vector, transpose

Arrays

Array commands a = [ ] b = [1; 2; 3; 4] c = [1 2; 3] (error) d = [1 2; 3 4] f = d(1,2) g(4,5) = 7

Arrays continued zeros(), ones(), eye() scalar vs. array arithmetic +, -, * (.*), / (./) ^ etc.