On September 14th, 2017, we published revised versions of our Privacy Policy, Terms of Service and Website Use Policy and published a Cookie Policy. Your continued use of Lynda.com means you agree to these revised documents, so please take a few minutes to read and understand them.

Creating functions

Let's investigate how to create a simple function in MATLAB. …Functions are very similar to scripts in many ways but they have different output …and input protocols. Whereas a script is meant to run on its …own and runs the same way every time. A function takes an input from the user …each time it runs. Making it a more general and powerful tool. …Similarly whereas scripts don't usually have predefined output other than what is …displayed on the command window or on a plot.…

Functions directly provide their output for use by other scripts or functions …that call them. For this video I will rewrite the script …created in the previous video into a function. …To start with, click on the New dropdown menu and choose to create a new function. …Then save that function as practicefunction.m. …Right away you will see that rather than providing a blank screen, MATLAB …automatically writes in some basic information.…

The first line is the most important because it defines how the function can …be used. Essentially when you type in the function …

Resume Transcript Auto-Scroll

Author

Released

6/12/2013

MATLAB is one of the most popular programming languages today for engineers and scientists, and with good reason—it allows data analysts to work efficiently with large amounts of data. Let author Patrick Royal show you how to harness the MATLAB tools and gain a level of fluency with the language. He shows how to work with the core syntax, which is significantly different than other programming languages; create scripts and functions; debug your program; and finally, work with plots, annotations, and images. The final chapter covers external toolboxes—extensions and libraries that automate, complement, and enhance existing MATLAB functionality.