From the course: MATLAB 2018 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a user-defined function

Create a user-defined function - MATLAB Tutorial

From the course: MATLAB 2018 Essential Training

Start my 1-month free trial

Create a user-defined function

- [Instructor] So far in this course, I have shown you how to work in MATLAB using the command window. In this movie, I'm going to show you how to save your commands as a script, that way you can run functions and other procedures whenever you like. I have a blank command window in front of me, but what I really need is a new script, a code window. So for that I will go to the home tab of the user interface, and click new script. Doing so displays the editor window, and from here I can create a function. It starts out as you might imagine with the function keyword, followed by a space, and then the name of the output variable. And this will be the variable that is calculated within the body of the function. In this case, I will call it crcmf, which is short for circumference. Then a space, then an equal sign. Now I need to type in the name of the function that will be used inside of MATLAB. That will be circumf another abbreviation for circumference, left parenthesis, and I need to…

Contents