设置首页收藏本站在线聊天
授权版本:2024_09
开启左侧

[HALCON文档] Halcon中数值操作相关函数

[复制链接]
绝地武士 发表于 2021-9-12 10:21:39 | 显示全部楼层 |阅读模式
tuple_min        
返回元组中最小的一个元素
min(t)            
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupMin:=min(tup)
  3. *tupMin = 2
复制代码

tuple_min2
返回两个元组中最含最小元素的元组
min2(t1,t2)
  1. tup1:=[2,10,15,5,8,55,69,43]
  2. tup2:=[100,101,102,103,104,105,106,107]
  3. tupMin:=min2(tup1,tup2)
  4. *tupMin = [2,10,15,5,8,55,69,43]
复制代码

tuple_max        
返回元组中最大的一个元素
max(t)            
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupMax:=max(tup)
  3. *tupMax = 69
复制代码

tuple_max2
返回两个元组中最含最大元素的元组
max2(t1,t2)
  1. tup1:=[2,10,15,5,8,55,69,43]
  2. tup2:=[100,101,102,103,104,105,106,107]
  3. tupMax:=max2(tup1,tup2)
  4. *tupMax = [100,101,102,103,104,105,106,107]
复制代码

tuple_sum
返回所有元组元素的总和或字符串连接
sum(t)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupSum:=sum(tup)
  3. *tupSum = 207
  4. tupStr:=['China','Beijing','Chaoyang','Road']
  5. tupSum:=sum(tupStr)
  6. *tupSum = 'ChinaBeijingChaoyangRoad'
复制代码

tuple_mean
返回元组的平均值
mean(a)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupMean:= mean(tup)
  3. *tupMean = 25.875
复制代码

tuple_deviation
返回元组的标准偏差
deviation(a)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupDiv:= deviation(tup)
  3. *tupDiv = 25.9033
复制代码

tuple_cumul
返回元组的累计总和
cumul(a)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupCumul:= cumul(tup)
  3. *tupCumul = [2,12,27,32,40,95,164,207]
复制代码

tuple_median
返回元组从小到大排序后的中间值
median(a)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupMedian:= median(tup)
  3. *tup1 := [2,5,8,10,15,43,55,69]
  4. *tupMedian = 15
复制代码

tuple_select_rank
返回元组从小到大排序后第i位索引的元素
select_rank(a,i)
  1. for i:= 0 to |tup|-1 by 1
  2.     curEle := select_rank(tup,i)
  3. endfor
复制代码

tuple_sqrt
返回元组中每个元素的平方根
sqrt(a)
  1. tup:=[2,10,15,5,8,55,69,43]
  2. tupSqrt:= sqrt(tup)
  3. *tupSqrt = [1.41421,3.16228,3.87298,2.23607,2.82843,7.4162,8.30662,6.55744]
复制代码

tuple_deg
转换元组元素从弧度到角度
deg(a)
  1. tup:=[0.5,1.0,1.5,2.0,2.5,3.0,3.1415926]
  2. tupDeg:=deg(tup)
  3. *tupDeg = [28.6479,57.2958,85.9437,114.592,143.239,171.887,180.0]
复制代码

tuple_rad
转换元组元素从角度到弧度
rad(a)
  1. tup:=[28.6479,57.2958,85.9437,114.592,143.239,171.887,180.0]
  2. tupRad:=rad(tup)
  3. *tupRad = [0.5,1.0,1.5,2.0,2.5,3.0,3.1415926]
复制代码

tuple_real
转换整数到实数
real(a)
  1. Number:=520
  2. RealNum:=real(Number)
  3. *RealNum = 520.0
复制代码

tuple_int
转换实数到整数
int(a)
  1. Number:=520.1314
  2. IntNum:=int(Number)
  3. *IntNum = 520
复制代码

tuple_round

转换实数到整数(采取四舍五入法取整)
round(a)
  1. Number:=520.1314
  2. RoundNum:=round(Number)
  3. Number:=520.6999
  4. RoundNum:=round(Number)
复制代码

tuple_abs
转换整数或实数为它的绝对值
abs(a)
  1. Number:=-520.1314
  2. AbsNum:=abs(Number)
  3. Number:=520.1314
  4. AbsNum:=abs(Number)
  5. *AbsNum = 520.131
复制代码

tuple_fabs

转换实数(总是实数)为它的绝对值
fabs(a)
  1. Number:=-520.1314
  2. AbsNum:=fabs(Number)
  3. Number:=520.1314
  4. AbsNum:=fabs(Number)
  5. *AbsNum = 520.131
复制代码

tuple_ceil
不小于提供数的最小整数(向上取最小整)
ceil(a)
  1. Number:=520.1314
  2. CeilNum:=ceil(Number)
  3. *CeilNum = 521
复制代码

tuple_floor
不大于提供数的最大整数(向下取最大整)
floor(a)
  1. Number:=520.1314
  2. FloorNum:=floor(Number)
  3. *FloorNum = 520
复制代码

tuple_fmod
返回a1除以a2的余数
fmod(a1,a2)
  1. tup:=[2,5,8,12,15]
  2. fmodNum := fmod(tup,5)
  3. *fmodNum=[2.0,0.0,3.0,2.0,0.0]
复制代码

tuple_sgn
返回元组中元素的符号,以(1,0,-1)表示,符号正为1,0为0,符号负为-1
sgn(a)

  1. tup:=[2,-5,8,0,-12,15]
  2. tupSgn := sgn(tup)
  3. *tupSgn:=[1,-1,1,0,-1,1]
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表