EGR_102_Lab_05A_MATLAB_Functions

EGR_102_Lab_05A_MATLAB_Functions - MATLAB User-Defined...

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

View Full Document Right Arrow Icon
EGR 102 Lab 05A 1 MATLAB ® User-Defined Functions EGR 102 Lab 05A 2 User-Defined Functions Two types of MATLAB files: Scripts User-Defined Functions (“Functions”) Contain series of commands executed at once Created in the MATLAB Editor Saved with .m extension (M-Files) Difference concerns variables
Background image of page 1

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

View Full DocumentRight Arrow Icon
EGR 102 Lab 05A 3 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 05A 4 MATLAB Workspace A workspace is a group of variables, named containers , with each one holding a value Multiple workspaces in MATLAB: s Global (“Main”) Workspace used by Command Window and Scripts s Functions use own private workspaces, with variables only they can see when running
Background image of page 2
EGR 102 Lab 05A 5 Variables Input Variables Value is passed from the Global Workspace to the function’s Workspace. Output Variables Value is passed from the function’s Workspace to the Global Workspace. The only way of getting a value out of a function
Background image of page 3

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

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

Page1 / 7

EGR_102_Lab_05A_MATLAB_Functions - MATLAB User-Defined...

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

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