General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.

Slides:



Advertisements
Similar presentations
Inheritance Math 130 B Smith: Consider using the example in SAMS Teach Yourself C++ in 24 hours B Smith: Consider using the example in SAMS Teach Yourself.
Advertisements

General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 9/2/2009.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Functions.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
General Computer Science for Engineers CISC 106 Lecture 28 Dr. John Cavazos Computer and Information Sciences 04/29/2009.
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
General Computer Science for Engineers CISC 106 Lecture 22 Dr. John Cavazos Computer and Information Sciences 04/13/2009.
ENGG 1801 Engineering Computing MATLAB Lecture 2: Background for Week 4 Tutorial Simple Programming in MATLAB.
General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009.
General Computer Science for Engineers CISC 106 Lecture 20 Dr. John Cavazos Computer and Information Sciences 04/08/2009.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
General Computer Science for Engineers CISC 106 Lecture 12 Roger Craig Computer and Information Sciences 3/11/2009.
Top-down Program Design, Relational and Logical Operators
General Computer Science for Engineers CISC 106 Lecture 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
Top-down Program Design Selim Aksoy Bilkent University Department of Computer Engineering
General Computer Science for Engineers CISC 106 Lecture 23 Dr. John Cavazos Computer and Information Sciences 4/15/2009.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
General Computer Science for Engineers CISC 106 Lecture 06 Roger Craig Computer and Information Sciences 2/23/2009.
ME457 Mechatronic System Modeling MICHIGAN STATE UNIVERSITY Matlab® refresher Your objective: to dominate! My objective: to help you dominate!
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
259 Lecture 16 Numerical Differentiation and Integration in MATLAB; Function M-files.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Chapter 3: Using Spreadsheets in Analytical Chemistry CHE 321: Quantitative Chemical Analysis Dr. Jerome Williams, Ph.D. Saint Leo University.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Matlab Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 6/8/2009.
General Computer Science for Engineers CISC 106 Lecture 04 Dr. John Cavazos Computer and Information Sciences 09/10/2010.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Scientific Computing Introduction to Matlab Programming.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 11.
Lecture 13: 10/10/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
MCE 372 Engineering Analysis MATLAB Review. M ATLAB – What Is It ? Where Is It? Name is from matrix laboratory Powerful tool for – Computation and visualization.
Engineering Analysis – Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Introduction to Engineering MATLAB – 7 Script Files - 2 Agenda Script files continued.
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 COMS 261 Computer Science I Title: Functions Date: October 12, 2005 Lecture Number: 17.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 2/17/2010.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
The Circle. Examples (1) – (5) Determine the center and radius of the circle having the given equation. Identify four points of the circle.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Introduction to Programming Lecture 6. Functions – Call by value – Call by reference Today's Lecture Includes.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
General Computer Science for Engineers CISC 106 Lecture 27 Dr. John Cavazos Computer and Information Sciences 04/27/2009.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 9/9/2009.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
General Computer Science for Engineers CISC 106 Lecture 09 Dr. John Cavazos Computer and Information Sciences 03/04/2009.
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
Using Script Files and Managing Data
Introduction to Programming
General Computer Science for Engineers CISC 106 Lecture 03
Introduction to Programming
General Computer Science for Engineers CISC 106 Lecture 15
ME 123 Computer Applications I Lecture 4: Vectors and Matrices 3/14/03
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
ME 123 Computer Applications I Lecture 7: Basic Functions 3/20/03
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009

Lecture Overview How to save an m-file, diary command, how to submit work, labs/lab01.html labs/lab01.html Key points: concept of a function, importance of functions, m-files, comments with % sign,

MATLAB Ok, so now I have to calculate the area of 7000 circles >> area = pi * 0.7 * 0.7 >> area = pi * 9 * 9 >> area = pi * radius^2 Etc. Wouldn’t it be better to save the equation and input only one value (the radius) ? Solution is functions

Functions Top-down program design (pp ) Breaking problems down Code reuse (Don’t reinvent the wheel) How do we write functions in MATLAB?

Sample function circleArea function outputValue = circleArea(radius) outputValue = pi * radius ^ 2;

MATLAB m-files overview MATLAB script files are also known as m- files They end in.m file extension You can use the m file by typing the name of the m-file (without the.m extension)

MATLAB m-files Create a circleArea m-file How to save a file

Sample M-file circleArea.m to enter %circleArea.m %John Cavazos, 2/13/2009 %Description: calculates the area of a circle given the radius function outputValue = circleArea(radius) outputValue = pi * radius ^ 2;

Now, what if we want to calculate area of a ring A ring of two concentric circles we can use our circleArea function = -

Area of a ring pi * (radius1)^2 – pi * (radius2)^2 %Description: calculates the area of a ring given outer radius_1 and inner radius_2 function outputValue = ringArea(radius_1, radius_2) outputValue = circleArea(radius_1) - circleArea(radius_2);

Test area of a ring ringArea(2,1) ringArea(3,1) Etc.