Skip to main content

Introduction

Figure 16.0.1. Luckily for us, MATLAB functions aren’t THIS complicated.
Functions are a fundamental part of mathematics and most students are familiar with how they work. In math class, you were likely taught that you can think of functions like little machines (figure 16.0.2) that associate a unique number \(y\text{,}\) with any given number, \(x\text{.}\) You may have even learned the terminology that the \(x\) value is the input, and the \(y\) value is the output.
Figure 16.0.2. The function of a little number manipulation machine
If you can understand how a mathematical function works, you are actually well on your way to understanding how MATLAB functions work! MATLAB functions work in the same way as mathematical functions. You have one (or more inputs), manipulate the input(s) according to some rules, and then you return one (or more outputs).
In this chapter, we will learn the how to create our own MATLAB functions and why we should. That means learning: