LinearCombinationOfContVars
Calculates a linear combination of two continuous variables.
Syntax
LinearCombinationOfContVars(doc, resultName, contVar1, coeff1, contVar2, coeff2)
Parameters
Parameter |
Type |
Description |
---|---|---|
doc |
documentReference |
Reference to the document. |
resultName |
string |
The name of the result. |
contVar1 |
variableReference |
Reference to the first continuous variable. |
coeff1 |
number |
Coefficient for the first continuous variable |
contVar2 |
variableReference |
Reference to the second continuous variable. |
coeff2 |
number |
Coefficient for the second continuous variable |
Return
None.
Note
This function calculates a linear combination of two continuous variables. The values of the resulting variable are:
contVar1_value*coeff1 + contVar2_value*coeff2
Starting with version 5.104, you can get the same result by using math operations (multiplication and addition) on document continuous variables:
doc['contVar1_2_Average'] = doc['contVar1']*0.5 + doc['contVar2']*0.5
Examples
Python
import nex
doc = nex.GetActiveDocument()
# calculate average of contVar1 and contVar2
nex.LinearCombinationOfContVars(doc, "average", doc["FP01"], 0.5, doc["FP02"], 0.5)
NexScript
doc = GetActiveDocument()
% calculate average of contVar1 and contVar2
LinearCombinationOfContVars(doc, "average", doc["FP01"], 0.5, doc["FP02"], 0.5)