Lecture9 - EGR 106 Lecture 9 Function Files Functions...

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

View Full Document Right Arrow Icon
EGR 106 – Lecture 9 Function Files Functions Concept Basic Structure Examples and Applications Textbook: 7.1 - 7.7
Background image of page 1

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

View Full DocumentRight Arrow Icon
Function Concept So far: Have used Matlab’s built-in functions; for example sin(x), exp(x), abs(x), . . . Have started writing scripts Function: Reusable script Sometimes called a subprogram Useful as a building block for larger programs Computes an output from an input
Background image of page 2
Building Block Concept: % Main Program function ------ ------ ------ function #1 ------ ------ ------ function #2 ------ ------ ------ ------ ------ function #3 ------ ------ ------ ------ ------ ------ ------ function #1 ------ ------ ------ function #2 ------ ------ ------ function #3 ------ ------ ------
Background image of page 3

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

View Full DocumentRight Arrow Icon
Function File Format First line of the file must be of the form:
Background image of page 4
Example: Convert Degrees to Radians Function: deg2rad
Background image of page 5

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

View Full DocumentRight Arrow Icon
Usage: Syntax is just like a built-in functions Application is independent of the variable names within the function (x,y) Executed by typing name (input)
Background image of page 6
Rules for Functions Again first line of the file must be of the form:
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course EGR 106 taught by Professor Taggart during the Spring '09 term at Rhode Island.

Page1 / 27

Lecture9 - EGR 106 Lecture 9 Function Files Functions...

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

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