Lecture_06_horowitz - 1 E7: INTRODUCTION TO COMPUTER E7:...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
E7 L6 1 E7: INTRODUCTION TO COMPUTER E7: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND PROGRAMMING FOR SCIENTISTS AND ENGINEERS ENGINEERS Lecture Outline The concept of a function MATLAB functions User defined functions Copyright 2007, Horowitz, Packard. This work is licensed under the Creative Commons Attribution-Share Alike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Professor Horowitz won’t hold office hours tomorrow (needs to attend a research meeting) 3 handouts today Download assignment 3 from bspace!!! Ken will also e-mail E7 L6 2
Background image of page 2
E7 L6 3 The concept of a function A rule that assigns to each value of the input , a corresponding output value. Symbolically: { } { } 1 2 1 2 , ,..., ( , ,..., ) n m y y y x x x = FUNCTION input output
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L6 4 The concept of a function Pictorially: Input/output data can be of various types, e.g., numbers, strings, arrays, etc. x 1 x 2 x n y 1 y 2 y m FUNCTION . . . .
Background image of page 4
E7 L6 5 FUNCTIONS in programming FUNCTIONS in programming A set of commands that execute a “task” that can be reuse in several instances. These commands are written as a function Functions are use to break down a large task into a collection of smaller tasks. Functions are also called subroutines, methods , etc.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L6 6 MATLAB functions MATLAB contains a number of useful functions, Simple mathematical functions (e.g., sin, atan, log, exp, sqrt, abs ) Array functions (e.g., size, sort, sum, max ) String functions (e.g., strmatch, upper ) Cell functions (e.g., celldisp, cellplot ) Structure functions (e.g., fieldnames, rmfield )
Background image of page 6
E7 L6 7 MATLAB functions MATLAB functions Existing MATLAB functions are distinguished into two categories: Built-in functions implemented in a programming language other than Matlab (C or assembly language). Matlab-programmed functions Written as m-files The type command displays the content of an m-file.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Examples of type outputs Examples of type outputs Built-in function: Matlab-programmed functions >> type sin sin is a built-in function. >> type linspace
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/17/2011 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at University of California, Berkeley.

Page1 / 23

Lecture_06_horowitz - 1 E7: INTRODUCTION TO COMPUTER E7:...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online