Download HiQ User Manual - National Instruments
Transcript
06chap04.fm Page 10 Tuesday, November 26, 1996 4:00 PM
Chapter 4
Understanding HiQ-Script
The following script represents a different case.
a[2,3] = 2;
a = 0;
When HiQ runs this script it generates the value 0 for a.
Polynomials
HiQ has real and complex polynomial objects. These objects make
polynomial algebra in HiQ-Script as easy as linear algebra. You can
declare a polynomial using one of the following syntaxes.
myPoly = {poly: 1,2,3};
or
myPoly = {poly: "x^2 + 2x + 3"};
Either of these declarations generate the polynomial x 2 + 2x + 3. To
declare a complex polynomial, insert any complex scalar expression in
the polynomial initialization syntax, as in the following example.
pz1 = {poly: (1,2), 1 + 2*<i>};
pz2 = {poly: "(1,2)x + (1,2)"};
You can operate on a polynomial as you would operate on other data
types, as in the following example.
p2 = myPoly + myPoly;
p3 = p2 * myPoly;
To evaluate a polynomial at a particular value treat the polynomial as
you would a single input function, as in the following example.
y = p4(3);
Furthermore, anywhere that you can use a function in HiQ you can use
a polynomial. For example, you can perform numerical integration of a
polynomial as follows.
p = {poly: 3,2,1};
result = integrate(p, -1, 1);
Text Objects
You can set text objects, also called strings, to any combination of
ASCII characters.
The following statement sets the variable text to the value "HiQ".
text = "HiQ";
HiQ User Manual
4-10
© National Instruments Corporation