Summary: This module covers basic operations in LabVIEW MathScript.
LABVIEW MATHSCRIPT has many
arithmetic operations and functions built in. Most of them are
straightforward to use. The Table below lists some commonly used
scalar operations; in this table, x and y are scalars. (A scalar is a single number.)
| Operation | LABVIEW MATHSCRIPT |
|---|---|
x-y |
|
x+y |
|
x*y |
|
x/y |
|
x^y |
|
exp(x) |
|
log10(x) |
|
log(x) |
|
log2(x) |
Expressions are formed from numbers, variables, and these operations. The operations have different precedences. The ^ operation has the highest precedence; ^ operations are evaluated before any other operations. Multiplication and division have the next highest precedence, and addition and subtraction have the lowest precedence. Precedence is altered by parentheses; expressions within parenthesesare evaluated before expressions outside parentheses.
The Table below shows several mathematical formulas, the corresponding LABVIEW MATHSCRIPT expressions, and the values that LABVIEW MATHSCRIPT would compute for the expressions.
| formula | LABVIEW MATHSCRIPT Expression | Computed Value |
|---|---|---|
|
|
5^2+4^2 |
41 |
|
|
(5+4)^2 |
81 |
|
|
(2 + 3)/(4 - 5) |
-5 |
|
|
log10(100) |
2 |
|
|
log(4*(2+3)) |
2.9957 |
In addition to scalars, LABVIEW MATHSCRIPT can operate on matrices. Some common matrix operations are shown in the Table below; in this table, M and N are matrices.
| Operation | LABVIEW MATHSCRIPT |
|---|---|
M*N |
|
inv(M) |
|
M' |
|
| det( |
det(M) |
LABVIEW MATHSCRIPT functions length and size are used to
find the dimensions of vectors and matrices, respectively.
LABVIEW MATHSCRIPT can perform an operation on each element of a vector or matrix. To perform an arithmetic operation on each element in a vector (or matrix), rather than on the
vector (matrix) itself, then the operator should be preceded by
".", e.g .*, .^ and ./.
Let A^2 will return
A.^2 will return
Given a vector x, compute a vector y having elements
y=1./sin(x)
Note that using / in place of ./ would result in the (common) error
Matrix dimensions must agree.
LABVIEW MATHSCRIPT has excellent support for complex
numbers with several built-in functions available. The imaginary
unit is denoted by i or (as preferred in electrical engineering) j.
To create complex variables
z1 = 7 + j and z2 = 2*exp(j*pi)
The Table below gives an overview of the basic
functions for manipulating complex numbers, where
| LABVIEW MATHSCRIPT | |
|---|---|
| Re( |
real(z) |
| Im( |
imag(z) |
abs(z) |
|
| Angle( |
angle(z) |
conj(z) |
b and B are different variables and LABVIEW MATHSCRIPT will recognize the built-in function sum but not SUM. In previous versions, LABVIEW MATHSCRIPT was not case sensitive for function names.... at the end of
the line to indicate it continues on the next line.Splitting
y = a...
+ b...
c;
"This course provides a brief introduction to LabVIEW MathScript, the textual math componenet of LabVIEW. The modules for this course include typical syntax and programming methods commonly used […]"