Section 7. Installation
Table 27.
CRBasic Example. Array Assigned Expression: Fill Array Dimension
'Example: Fill Array Dimension
Public
A(3)
Public
B(3,2)
Public
C(4,3,2)
Public
Da(3,2) = {1,1,1,1,1,1}
Public
Db(3,2)
Public
DMultiplier(3) = {10,100,1000}
Public
DOffset(3) = {1,2,3}
BeginProg
Scan
(1,Sec,0,0)
A() = 1
'set all elements of 1D array or first dimension to 1
B(1,1)() = 100
'set B(1,1) and B(1,2) to 100
B(-2,1)() = 200
'set B(2,1) and B(3,1) to 200
B(-2,2)() = 300
'set B(2,2) and B(3,2) to 300
C(1,-1,1)() = A()
'copy A(1), A(2), and A(3) into C(1,1,1), C(1,2,1), and C(1,3,1),
'respectively
C(2,-1,1)() = A() * 1.8 + 32
'scale and then copy A(1), A(2), and A(3) into C(2,1,1),
'C(2,2,1), and C(2,3,1), respectively
'scale the first column of Da by corresponding multiplier and offset
'copy the result into the first column of Db
'then set second column of Db to NAN
Db(-1,1)() = Da(-1,1)() * DMultiplier() + DOffset()
Db(-1,2)() = NAN
NextScan
EndProg
7.9.6 Data Output: Calculating Running Average
The
AvgRun()
instruction calculates a running average of a measurement or
calculated value. A running average (
Dest
) is the average of the last N values
where N is the number of values, as expressed in the running-average equation:
where X
N
is the most recent value of the source variable and X
N-1
is the previous
value (X
1
is the oldest value included in the average, i.e., N-1 values back from
the most recent). NANs are ignored in the processing of
AvgRun()
unless all
values in the population are NAN.
AvgRun()
uses high-precision math, so a 32-bit extension of the mantissa is saved
and used internally resulting in 56 bits of precision.
Note
This instruction should not normally be inserted within a
For
/
Next
construct with the
Source
and
Destination
parameters indexed and
Reps
set to
1
.
Doing so will perform a single running average, using the values of the different
192
Содержание CR1000
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 32: ......
Страница 36: ......
Страница 38: ......
Страница 40: ......
Страница 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Страница 96: ......
Страница 98: ...98 ...
Страница 302: ......
Страница 350: ...Section 8 Operation Figure 91 Pulse Sensor Output Signal Types Figure 92 Switch Closure Pulse Sensor 350 ...
Страница 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Страница 454: ...Section 8 Operation 8 8 1 Data Display Figure 116 Displaying Data with the Keyboard Display 454 ...
Страница 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Страница 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Страница 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Страница 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Страница 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Страница 478: ......
Страница 506: ......
Страница 536: ......
Страница 636: ......
Страница 642: ......
Страница 644: ......
Страница 676: ......
Страница 677: ......