Mathematical Functions
Mathematical Functions
Basic math functions used in Explain Scripts. More…
Functions
Data type | Name and description |
REAL |
Abs (REAL number) Calculate the absolute value of a number. More… |
INDEX |
Abs (INDEX number) Calculate the absolute value of a number. More… |
REAL |
Exp (REAL number) Calculates ex. More… |
INDEX |
Index (ANY_TYPE Item) Converts REAL, BITS, BOOL, or STRING to an INDEX. More… |
REAL |
LineOpt (REAL OldTime) Returns a sample time that will result in successive samples 180° out of phase with the AC power-line (mains) frequency. More… |
REAL |
Log (REAL number) Calculate the natural (base e) logarithm of a number. More… |
REAL |
Log10 (REAL number) Calculate the base-10 logarithm of a number. More… |
REAL |
Modulus (REAL RealPart, REAL ImagPart) Calculate modulus of a complex number. More… |
REAL |
Phase (REAL RealPart, REAL ImagPart) Calculate the phase in degrees of a complex number. More… |
REAL |
Pow (REAL X, REAL Y) Calculate a number x raised to a power y, xy. More… |
INDEX |
Rand (INDEX number) Create a random number from 0 to RAND_MAX (32767). More… |
REAL |
Real (ANY_TYPE Item) Convert INDEX, BITS, BOOL, or STRING to a REAL. More… |
REAL |
Round (REAL numbers, INDEX places) Round a REAL value to a known number of decimal places. More… |
REAL |
Sqrt (REAL number) Calculates the square root of a number. More… |
Detailed Description
Calculate the absolute value of a number. The number can be an INDEX or a REAL. The value returned is the same type as the argument.
Parameters
Number The number for which the absolute value is desired.
Returns
Result The absolute value of Number
INDEX Abs (INDEX number
Calculate the absolute value of a number.
The value returned is the same type as the argument.
Parameters
Number The number for which the absolute value is desired.
Returns
Result The absolute value of Number
Calculate ex.
Parameters
Number The exponent of e
Returns
Result The result of eNumber
Convert REAL, BITS, BOOL, or STRING to an INDEX.
Parameters
Item Item to be converted to an INDEX
Returns
Converted The converted Item
Return a sample time that will result in successive samples 180 degrees out of phase with the AC power line frequency.
Parameters
OldTime The time used as the basis for the calculation.
Returns
NewTime The time calculated to result in successive sample that are out of phase with the AC power line.
Calculate the natural (base e) logarithm of a number.
Parameters
Number Number to find the log of.
Note
If Number < 0, the absolute value is taken first.
Returns
Result The calculated result
Calculate the base-10 logarithm of a number.
Note
If Number < 0, the absolute value is taken first.
Parameters
Number Number to find the log10 of.
Returns
Result The calculated result
REAL Modulus ( REAL RealPart, REAL ImagPart )
Calculate modulus of a complex number.
Modulus = sqrt(Re*Re + Im*Im)
Parameters
RealPart Real part of the complex number.
ImagPart Imaginary part of the complex number.
Returns
Result The result of the calculation.
REAL Phase ( REAL RealPart, REAL ImagPart )
Calculate the phase in degrees of a complex number.
Phase = arctan(im/re)
Parameters
RealPart Real part of the complex number.
ImagPart Imaginary part of the complex number.
Returns
Result The result of the calculation.
Calculate a number raised to a power, xy.
Parameters
X Base value
Y Exponent
Returns
Result The result of the calculation.
Calculate a random number from 0 to RAND_MAX (32767).
Parameters
Number Can be any one of the following values:
Value Result
Number = NIL 0 < Result < RAND_MAX
Number < 0 Result = RAND_MAX
Number > 0 Random number generator is re-seeded
Returns
Result The randomly generated number
Convert INDEX, BITS, BOOL, or STRING to a REAL.
Note
Anything other than a legal arguments is converted to 0.000
Parameters
Item Item to be converted to a REAL
Returns
Converted The converted Item
REAL Round ( REAL Numbers, INDEX Places)
Round a REAL value to a known number of decimal places.
Parameters
Number The quantity to be rounded
Places The number of decimal places desired.
Returns
Rounded The resulting number
Calculates the square root of a number.
Parameters
Number The number to square-rooted.
Note
If Number < 0, the absolute value is taken first.
Returns
Result The calculated result.
Comments are closed.