USER-DEFINED FUNCTIONS
There are three types of functions:
- Functions that calculate and return one value.
- Functions that calculate and return multiple values.
- Functions that accomplish some task (e.g. print to screen) without returning any values
RETURNING ONE VALUE
- user-defined function format example (to calculate area):
- help to the function:
- type command to see the script and function:
- multiple inputs:
RETURNING MORE THAN ONE VALUE
- functions [area, circumference] = my_circle(radius)
- calling the function using [a, c] = my_circle(4)
- using vector of inputs in the function:
- calling this function for a single variable for the output:
FUNCTIONS THAT ACCOMPLISH A TASK WITHOUT RETURNING VALUES
- function that print 2 given numbers: