# How to create a matlab function

### How do you create a function in Matlab?

**If your**

**function**returns one output, you can specify the output name after the**function**keyword.**function**myOutput = myFunction(x) If your**function**returns more than one output, enclose the output names in square brackets.**function**[one,two,three] = myFunction(x)**function**myFunction(x)

### How do I create a function M file in Matlab?

### How do I create a .m file?

To

**create an m**–**file**, choose New from the**File**menu and select Script. This procedure brings up a text editor window in which you can enter**MATLAB**commands. To save the**m**–**file**, simply go to the**File**menu and choose Save (remember to save it with the ‘.**m**‘ extension).