Home > Support > NI Product Manuals > LabVIEW Communications System Design Suite 1.0 Manual

Complete the following steps to create a user-defined MathScript function and call this function in a MathScript Node. The user-defined function returns both the sum and the difference of two input values.

First, create the user-defined function.

  1. Click Add Item in the Files pane.
  2. Select MathScript. The document editor opens.
  3. Enter the following code in the document editor:
    function [sum, difference] = sumdiff(a, b)
      %Calculates the sum and the difference of a and b
      sum = a + b
      difference = a - b
    end
  4. Right-click the MathScript document tab and click Rename. LabVIEW marks the function name.
  5. Enter sumdiff.

Now create the MathScript Node with the MathScript code that calls the user-defined function.

  1. Click Add Item in the Files section.
  2. Select VI. The VI editor opens.
  3. Click the Diagram selector.
  4. Open the Math palette.
  5. Select MathScript Node. A cross cursor appears.
  6. Drag open a MathScript Node on the diagram. A MathScript Node frame appears.
  7. Enter the following code in the MathScript Node:
    [D, E] = sumdiff(1, 2)
  8. Right-click D in the MathScript Node and select Create»Output: D.
  9. Right-click the D output on the MathScript Node frame, select Create Indicator, and click into the diagram in order to place the indicator.
  10. Repeat steps 13 and 14 for E in the MathScript Node.
  11. Click the Panel selector.
  12. Drag all of the indicators in the unplaced items tray to the panel.
  13. Click Run. The indicators show the results for D and E.