Create user-defined functions to separate recurrent calculations from the main program in a MathScript Node.
First, create the user-defined function.
The following procedure demonstrates how to create a user-defined MathScript function and call this function in a MathScript Node using a specific example. The example returns both the sum and the difference of two input values. The steps you need to take to complete your specific task might be different than the following steps.
function [sum, difference] = sumdiff(a, b) %Calculates the sum and the difference of a and b sum = a + b difference = a - b end
Now create the MathScript Node with the MathScript code that calls the user-defined function.
[D, E] = sumdiff(1, 2)