代码之家  ›  专栏  ›  技术社区  ›  Etan bbum

如何使所有列小于阈值?

  •  0
  • Etan bbum  · 技术社区  · 14 年前

    • 包含值<=指定阈值的列的列ID
    • 低于阈值的列数。

    for -循环?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Amro    14 年前
    >> thresh = 9;
    >> x = randi(20, [1 10])
    x =
        17    19     3    19    13     2     6    11    20    20
    >> xBelowInd = find(x <= thresh)
    xBelowInd =
         3     6     7
    >> num = length(xBelowInd)
    num =
         3
    >> x(xBelowInd)
    ans =
         3     2     6
    
        2
  •  1
  •   Jonas    14 年前

    我很确定这是个复制品,但我今天的搜索力很弱。

    不管怎样,你可以用 find

    columnId = find(array<threshold)
    numberOfColumnsBelowThreshold = length(columnId)