【问题标题】:the first time an element in a vector is larger than another vector in dolphindb向量中的元素第一次大于 dolphindb 中的另一个向量
【发布时间】:2021-12-24 07:31:39
【问题描述】:

我在 dolphindb 中有 2 个长度相同的向量(x 和 y)。如何获得第一次(或第 100 次)x 中的元素大于 y 中的相应元素?我可以编写一个循环,但由于 dolphindb 是一种基于向量的语言,我觉得这可能不是最快的方法。

【问题讨论】:

    标签: dolphindb


    【解决方案1】:

    尝试使用函数at 指定布尔表达式并在向量中定位元素。语法为at(X, [index])。修改索引来改变条件。

    例如:

    a=1..1000
    b=1000..1
    at(a>b)[0]
    //return the index 500
    
    a[at(a>b)[99]]
    //return the value 600
    

    【讨论】:

      猜你喜欢
      • 2015-07-19
      • 2014-05-21
      • 1970-01-01
      • 1970-01-01
      • 2019-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多