E7_L6_Functions_F08 - 1 E7: INTRODUCTION TO COMPUTER...

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

View Full Document Right Arrow Icon
1 E7: INTRODUCTION TO COMPUTER ROGRAMMING FOR SCIENTISTS AND PROGRAMMING FOR SCIENTISTS AND ENGINEERS Lecture Outline The concept of a function ATLAB functions MATLAB functions User defined functions opyright 2007 Horowitz Packard This work is licensed under the Creative Commons Attribution- hare E7 L6 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. 2 The concept of a function rule that assigns to each value of the put A rule that assigns to each value of the input , a corresponding output value. Symbolically: { } { } 12 , ,..., ( , ,..., ) nm yy y xx x = FUNCTION input utput E7 L6 output 3 The concept of a function ictorially: Pictorially: x 1 y 1 x 2 y 2 FUNCTION . . x n y . . Input/output data can be of various types, e.g., numbers, m E7 L6 pp y p , g , , strings, arrays, etc. 4 FUNCTIONS in programming set of commands that execute a “task” at can be • 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 ollection of smaller tasks collection of smaller tasks. unctions re also called ubroutines methods Functions are also called subroutines, methods , etc. E7 L6
Background image of page 1

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

View Full DocumentRight Arrow Icon
5 MATLAB functions ATLAB contains a number of useful functions MATLAB contains a number of useful functions, imple mathematical functions (e.g., in, atan, 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 ) E7 L6 Structure functions (e.g., fieldnames, rmfield ) 6 MATLAB functions xisting MATLAB functions are distinguished into two Existing MATLAB functions are distinguished into two categories: Built-in functions plemented in a programming language other than implemented in a programming language other than Matlab (C or assembly language). Matlab-programmed functions Written as m-files E7 L6 The type command displays the content of an m-file.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

E7_L6_Functions_F08 - 1 E7: INTRODUCTION TO COMPUTER...

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

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