Sub2 Function

Sub2 subtracts all values of a list with each value of the other list


Function

The Sub2 function is used to subtract two lists. Each element of the first list is subtracted with each element of the second list. The result is a table. The size of the table corresponds to the lengths of the list a * list b .

For a simple calculation, the expression x = Sub2 (a, b) is identical to x [] = a-b .

For more complex expressions with more than two lists in the arguments, the use of the function Sub2 can be required. The differences are shown below.

Syntax

Sub2 (a, b)

Examples



In the following example, an element of c is added to each line of the result of Sub2 (a, b) .
The result is a table with 3 lines.



In the following example, each element of b is subtracted from each element of a . Then each element of c is added to each element of the resulting table. The result is a three-dimensional data field. The index display shows three consecutive tables.

Practical example

In the following example, the resonance frequency is calculated from three different capacitances C and inductances L. The result is a table containing the results of all possible combinations.