EGR_102_Lab_04B_MATLAB_Functions

EGR_102_Lab_04B_MATLAB_Functions - MATLAB User-Defined...

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

View Full Document Right Arrow Icon
MATLAB ® User-Defined Functions EGR 102 - Lab 04B 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Saving Work in MATLAB ® Two types of MATLAB files: Scripts User-Defined Functions (“Functions”) Both contain a series of commands executed at once Both are created in the MATLAB Editor Both are saved with a .m extension (M-Files) Both must be in the Current Folder The difference concerns variables EGR 102 - Lab 04B 2
Background image of page 2
Saving Work in MATLAB ® Scripts They automate repetitive tasks They contain a collection of commands that you would execute in the command window Functions They operate on information (inputs) that are fed into them and return values (outputs) to the global workspace Functions have a separate (private) workspace EGR 102 - Lab 04B 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
User-Defined Functions Accept input arguments and return outputs to the Global Workspace All other variables in User-Defined Functions are not returned to the Global Workspace Same as Built-In Functions, except created by you >> y = sin(x) Command (Function Name) Returns (Output Variables) Arguments (Input Variables) EGR 102 - Lab 04B 4
Background image of page 4
MATLAB Workspace A workspace is a group of variables, named containers , with each one holding a value Multiple workspaces in MATLAB: Global (“Main”) Workspace, used by Command
Background image of page 5

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

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

This note was uploaded on 04/02/2012 for the course EGR 100 taught by Professor Hinds during the Fall '08 term at Michigan State University.

Page1 / 13

EGR_102_Lab_04B_MATLAB_Functions - MATLAB User-Defined...

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

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