Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of function it is, all the functions should be defined, and all the function definitions consist of the header and the body. Also, the function should be called in order for it to be utilized. Categorizing the functions is fairly arbitrary, but there are distinctions between these three types of functions, involving the format of the function headers and also the way in which the functions are called.
(A) In common, any function in MATLAB consists of
- the reserved word function
- (if the function returns values, the names of the output arguments followed by the assignment operator =)
- the name of the function (Significant: This must be similar as the name of the M-file in which this function is stored in order to avoid the confusion)
- the input arguments in parentheses,when there are any (separated by the commas if there is more than one)
(B) A comment which describes what the function does.
(C) The body of the function that involves all statements, involving of assigning values to all the output arguments if there are any.