* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Basic operations in LabVIEW MathScript
Eigenvalues and eigenvectors wikipedia , lookup
Linear algebra wikipedia , lookup
Tensor operator wikipedia , lookup
Non-negative matrix factorization wikipedia , lookup
Basis (linear algebra) wikipedia , lookup
Cartesian tensor wikipedia , lookup
Bra–ket notation wikipedia , lookup
Four-vector wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
Gaussian elimination wikipedia , lookup
Matrix multiplication wikipedia , lookup
OpenStax-CNX module: m13712 1 Basic operations in LabVIEW MathScript ∗ Anthony Antonacci Based on Basic operations in MATLAB† by Anders Gjendemsjø Darryl Morrell This work is produced by OpenStax-CNX and licensed under the ‡ Creative Commons Attribution License 2.0 Abstract This module covers basic operations in LabVIEW MathScript. 1 Basic Operations on Numbers LABVIEW MATHSCRIPT has many arithmetic operations and functions built in. Most of them are straightforward to use. The Table (Table 1: Common scalar mathematical operations in LABVIEW MATHSCRIPT) below lists some commonly used scalar operations; in this table, x and y are scalars. (A scalar is a single number.) Common scalar mathematical operations in LABVIEW MATHSCRIPT Operation LABVIEW MATHSCRIPT x−y x-y x+y x+y xy x*y x y x/y continued on next page ∗ Version 1.1: Aug 2, 2006 12:56 pm -0500 † http://cnx.org/content/m13439/1.3/ ‡ http://creativecommons.org/licenses/by/2.0/ http://cnx.org/content/m13712/1.1/ OpenStax-CNX module: m13712 2 x^y xy x exp(x) log10 (x) log10(x) ln (x) log(x) log2 (x) log2(x) e Table 1 Expressions are formed from numbers, variables, and these operations. The operations have dierent 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. Example 1 The Table (Table 2: Example LABVIEW MATHSCRIPT Expressions) below shows several mathematical formulas, the corresponding LABVIEW MATHSCRIPT expressions, and the values that LABVIEW MATHSCRIPT would compute for the expressions. Example LABVIEW MATHSCRIPT Expressions formula LABVIEW MATHSCRIPT Expression Computed Value 52 + 42 5^2+4^2 41 2 (5+4)^2 81 2+3 4−5 (2 + 3)/(4 - 5) -5 log10 (100) log10(100) 2 ln (4 × (2 + 3)) log(4*(2+3)) 2.9957 (5 + 4) Table 2 2 Basic Operations on Matrices In addition to scalars, LABVIEW MATHSCRIPT can operate on matrices. Some common matrix operations are shown in the Table (Table 3: Common matrix mathematical operations in LABVIEW MATHSCRIPT) below; in this table, M and N are matrices. Common matrix mathematical operations in LABVIEW MATHSCRIPT Operation LABVIEW MATHSCRIPT continued on next page http://cnx.org/content/m13712/1.1/ OpenStax-CNX module: m13712 3 M*N MN M −1 inv(M) T M' M det(M ) det(M) Table 3 LABVIEW MATHSCRIPT functions length and size are used to nd 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 ./. Example2 Let A = 1 1 1 1 1 1 1 1 . Then A^2 will return AA = 2 2 2 2 , while A.^2 will return 12 12 12 12 = . Example 3 1 . This can be easily be done Given a vector x, compute a vector y having elements y (n) = sin(x(n)) in LABVIEW MATHSCRIPT by typing y=1./sin(x) Note that using / in place of ./ would result in the (common) error Matrix dimensions must agree. 3 Complex numbers 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 + i and z2 = 2eiπ simply enter z1 = 7 + j and z2 = 2*exp(j*pi) The Table below gives an overview of the basic functions for manipulating complex numbers, where z is a complex number. Manipulating complex numbers in LABVIEW MATHSCRIPT LABVIEW MATHSCRIPT Re(z ) Im(z ) real(z) |z| abs(z) Angle(z ) angle(z) imag(z) continued on next page http://cnx.org/content/m13712/1.1/ OpenStax-CNX module: m13712 4 conj(z) z∗ Table 4 4 Other Useful Details • A semicolon added at the end of a line tells LABVIEW MATHSCRIPT to suppress the command output to the display. • LABVIEW MATHSCRIPT Version 1.0 is case sensitive for both variables and functions; for example, b and B are dierent 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. • Often it is useful to split a statement over multiple lines. To split a statement across multiple lines, enter three periods ... at the end of the line to indicate it continues on the next line. Example 4 Splitting y = a + b + c over multiple lines. y = a... + b... c; http://cnx.org/content/m13712/1.1/