User-defined MathScript functions have the following syntax:

function outputs = function_name(inputs)
script
end

The following list describes the function elements:

• function defines the beginning of a function.
• outputs defines the names of the output variables. If a function has more than one output variable, the names of the variables must be enclosed in square brackets and separated by spaces or commas. outputs is optional.
• function_name defines the name of the function.
• inputs defines the names of the input variables. If a function has more than one input variable, the names of the variables must be separated by commas. inputs is optional.
• script defines the executable body of the function.
• end ends the function. end is optional.

The following list shows the valid function signatures for a user-defined MathScript function with the name foo:

• function foo
• function foo()
• function foo(g)
• function foo(g, h)
• function a = foo
• function a = foo()
• function a = foo(g)
• function a = foo(g, h)
• function [a b] = foo
• function [a b] = foo()
• function [a b] = foo(g)
• function [a b] = foo(g, h)
• function [a, b] = foo(g, h)