Lecture 7

# Lecture 7 - Lecture 7 User-defined functions(Part 1 BMEn...

This preview shows pages 1–4. Sign up to view the full content.

10/19/2010 1 Lecture 7: User-defined functions (Part 1) BMEn 2401 Programming for Biomedical Engineers Rich Beck October 18, 2010 Today’s lecture Script M-file Review of MATLAB built-in functions User-defined functions 2

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

View Full Document
10/19/2010 2 Script M-file A script file or a program is a sequence of MATLAB commands, written in an M-file. Generally, the output of the script file is shown in the command window. By using a script file, a program can be edited and executed multiple times. Variables created by a script file stay in the Workspace until they are deleted by the clear command. A script file can “call” (execute) a MATLAB built-in function or a user-defined function 3 Script file % This program converts temperature % in Celsius to Fahrenheit Temperature_C = . .. input('Enter the temperature in Celsius:'); Temperature_F = Temperature_C * 1.8 +32; disp ( 'The temperature in Fahrenheit is:' ) disp (Temperature_F) 4
10/19/2010 3 MATLAB Functions OUTPUT = MATLABFunction (INPUT) MATLAB Function INPUT OUTPUT Inputs and outputs of a function can be any combination of scalars, arrays, and strings. 5 Functions Functions M-files that accept input arguments and return output arguments Perform specific tasks (ex. repetitive calculations) “Called” in a script file or other function To view MATLAB function M-files, from MATLAB Open b C:\Program Files\MATLAB\R2009b\toolbox\matlab Subfolders contain M-files to MATLAB built-in functions

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/10/2011 for the course BMEN 2051 taught by Professor S during the Fall '10 term at Minnesota.

### Page1 / 13

Lecture 7 - Lecture 7 User-defined functions(Part 1 BMEn...

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

View Full Document
Ask a homework question - tutors are online