General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009.

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
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 04 Roger Craig Computer and Information Sciences 9/11/2009.
A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
Lecture 7 Sept 29 Goals: Chapters 5 and 6. Scripts Sequence of instructions that we may want to run can be stored in a file (known as script). by typing.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
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 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
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 07 James Atlas Computer and Information Sciences 9/18/2009.
CIS 101: Computer Programming and Problem Solving Lecture 5 Usman Roshan Department of Computer Science NJIT.
CIS 101: Computer Programming and Problem Solving Lecture 4 Usman Roshan Department of Computer Science NJIT.
General Computer Science for Engineers CISC 106 Lecture 09 James Atlas Computer and Information Sciences 9/25/2009.
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
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.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
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.
Function M-File Numerical Computing with. MATLAB for Scientists and Engineers.
General Computer Science for Engineers CISC 106 Lecture 04 Dr. John Cavazos Computer and Information Sciences 09/10/2010.
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 2/10/2010.
Lecture 7 Sept 22 Goals: Chapters 5 and 6. Scripts Sequence of instructions that we may want to run can be stored in a file (known as script). by typing.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
COMP 116: Introduction to Scientific Programming Lecture 11: Functions.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Scientific Computing Introduction to Matlab Programming.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.
Covenant College November 27, Laura Broussard, Ph.D. Professor COS 131: Computing for Engineers Chapter 5: Functions.
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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.
MA/CS 375 Fall 2003 Lecture 3. .* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 2/17/2010.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
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.
General Computer Science for Engineers CISC 106 Lecture 14 James Atlas Computer and Information Sciences 08/10/2009.
Current Assignments Project 4 due next Saturday before midnight (Aug 2nd). Dinosaur classes. Comprehensive Final Exam on Thursday (July 31 st )
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Software Engineering Algorithms, Compilers, & Lifecycle.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 9/9/2009.
Introduction to Matlab
Lecture: MATLAB Chapter 1 Introduction
CS190/295 Programming in Python for Life Sciences: Lecture 1
Communication and Coding Theory Lab(CS491)
funCTIONs and Data Import/Export
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Using Script Files and Managing Data
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009

Lecture Overview How does our program work? More on Variables More on Expressions More on Functions M-files - Scripts versus functions

How does our program work? CPU Disk Memory Putting it together

Variables var = expression x = 2 * 2 comment = ‘This is a string’ area = circleArea(5)

Variables var = expression x = 2 * 2 comment = ‘This is a string’ area = circleArea(5) What type of data is stored in each variable?

Expressions Data + Operator ◦ ◦ circleArea(5)

Our ringArea(rad1, rad2) function out=ringArea(radius1, radius2) area1 = circleArea(radius1); area2 = circleArea(radius2); out = area1 - area2; Can you think of a simpler way to write this?

Expressions Data + Operator ◦ ◦ circleArea(5) Nested Expressions ◦ circleArea(5) + circleArea(3)

Functions Analogous to mathematical functions ◦ f(x) = x + 1 Each function is like a mini-program within the larger program itself Key to breaking problems down

Functions In MATLAB, the first line of a function takes the following form: function = ( )

Functions cont. The first line of a function: function = ( ) The return value can be a number, a string, a matrix, etc. Arguments ◦ Can be a list of zero or more variables ◦ Can also be numbers, strings, matrices

Functions Functions can call other functions Like in class on Monday: function outputValue = ringArea(rad_1, rad_2) outputValue = circleArea(rad_1) - circleArea(rad_2);

Functions Break down problems into subproblems ◦ Decomposition How big/small should a function be?

Problem Solving MP3 player ◦ Store song lists, store playlists, import/export songs, shuffle play, repeat play, etc.

Bank ATM Software What are inputs and outputs? Inputs: Output:

Bank ATM Software What functions might we need?

Bank ATM Software What functions might we need? Break it down even more?

M-files A script file ◦ Store commands in ◦ Running a script file (m-file) A function file ◦ Special type of m-file ◦ Contains a function name, arguments, etc., and implementation

Scripts vs. functions Functions have input and output parameters Scripts are a sequence of commands Functions are more flexible Function files have one function per file