你好,
我有一个数据系列,如下面的屏幕截图所示,并尝试仅选择“x +/- 0.3”范围内的数据,中心位于“y”的最大值。
我从突出显示的行中收到一条错误消息“SelectWhere 的参数未评估为 true 或 false,它是 [0]...”,如下所示。 令人费解的是,当仅应用 1 个条件时,最后一行就起作用了。
第 6 行脚本有什么问题? 谢谢!

Names Default To Here( 1 );
dt = current data table();
mxrow = dt << get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
print (mxrow, mxx);
dt << select where (:x < mxx + 0.3 & :x > mxx - 0.3);
dt << select where (:x < mxx + 0.3);
如果碰巧有多行最多,你可以这样做
Names default to here(1);
dt = New Table( "Test",
Add Rows( 46 ),
New Column( "x",
Set Values(
[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4,
5.5]
)
),
New Column( "y",
Set Values(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
1]
)
)
);
mxrow = dt << get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
dt << select where (Any(mxx - 0.3 <= :x < mxx + 0.3));
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :x ), Y( :y ) ),
);

第二个峰值上未选择的点是由于浮动误差。
因此,要解决您的问题,只需索引 mxx 的第一个值即可:
Names Default To Here( 1 );
dt = current data table();
mxrow = dt << get rows where (:y == col max(:y) );
mxx = (dt:x[mxrow])[1]; //Index into the matrix and extract the first item
print (mxrow, mxx);
dt << select where (:x < mxx + 0.3 & :x > mxx - 0.3);
dt << select where (:x < mxx + 0.3);
我认为 JMP 不喜欢您将矩阵与单个数字进行比较。
Names Default To Here(1);
dt = New Table("Untitled", Add Rows(3), New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3])));
max_x = [2];
dt << Select Where(:Column 1 > max_x); // will print message to log
wait(2);
min_x = 2;
dt << Select Where(:Column 1 < min_x);
你好,
尝试使用以下语法:
dt << select where (eval (mxx - 0.3) <= :x < eval (mxx + 0.3));
最好的,
TS