The Logical Operator , cmp

The logical operator is used to compare two quantities .

Usage in Calculator:

p0y = cmp(q0,q1,'mode')
or
p0y = cmp(q0,q1)
mode is an integer number, -8 < mode < 8
the ' on both side of mode must be present.
mode 0 is not used
If ",'mode')" is omitted it is set to 1 , (default value)

Mode Output If Symbol
1 1
-1
q0 >= q1
q0 < q1
ge
-1 1
-1
q0 <= q1
q0 > q1
le
2 1
-1
q0 > q1
q0 <= q1
gt
-2 1
-1
q0 < q1
q0 >= q1
lt
3 1
0
q0 >= q1
q0 < q1
GE
-3 1
0
q0 <= q1
q0 > q1
LE
4 1
0
q0 > q1
q0 <= q1
GT
-4 1
0
q0 < q1
q0 >= q1
LT
    
Mode Output If Symbol
5 1
0
-1
q0 > q1
q0 = q1
q0 < q1
gz
-5 1
0
-1
q0 < q1
q0 = q1
q0 > q1
lz
6 q0
q1
q0 >= q1
q0 < q1
gv
-6 q0
q1
q0 <= q1
q0 > q1
lv
7 q0
q1
q0 > q1
q0 <= q1
GV
-7 q0
q1
q0 < q1
q0 >= q1
LV
mode = 1 is default, also when using p0y = cmp(q0,q1)
q1 can be replaced by a constant (a number), but not q0

Example 1:
  p1y =  q0 * cmp(q0,150.0,'3') 
  This example set all data less than 150.0 to 0.0

Example 2:
  p1y = q0 - cmp(q0,1,'6') - cmp(q0,-1,'-6')
  This example cut the signal at +/- 1.0


Updated July 07, 2007 by Bjørn Lybekk