IDL 中的数组除法并对数组元素求和
我想知道如何划分两个数组
a = [1,2,3,4,5]
b = [2,4,6,8,15]
以
a/b = [0.5,0.5,0.5,0.5,0.3]
提前感谢您的帮助。
I was wondering how to divide two arrays
a = [1,2,3,4,5]
b = [2,4,6,8,15]
to get
a/b = [0.5,0.5,0.5,0.5,0.3]
Thanks in advance for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IDL 中的大多数操作都是按元素执行的,因此执行
c = a / b
将执行您想要的操作。Most operations in IDL are performed element-wise, so doing
c = a / b
will do what you want here.只需将数组表示为浮点变量或双精度数,即可获得所需的结果。否则,结果将是 0.0,因为它向上舍入到最小整数。我希望它会起作用。
Just express the arrays as floating variables or doubles, then you will get the desired results. Otherwise, the results will come as 0.0 as it rounds up to the lowest integer. I hope it will work.