基本上我正在尝试评估9种不同的语句并找到它们的最小绝对值。然后,我想将语句的NON绝对值返回到单元格中。这意味着要跨细胞扩展。所以我对此的输入是=getCorrectedRotation(E5:5,F5:5,F14:14)
我收到#REF错误。有什么想法吗?
function getCorrectedRotation(previous, current, step) {
var r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0
var points = step.length;
var output = [];
var i;
for (i = 0; i < points; i++) {
r = ((current[i]-previous[i])/step[i])
s = (((current[i]+360)-previous[i])/step[i])
t = (((current[i]-360)-previous[i])/step[i])
u = (((current[i]+360)-(previous[i]+360))/step[i])
v = (((current[i]+360)-(previous[i]-360))/step[i])
w = (((current[i]-360)-(previous[i]+360))/step[i])
x = (((current[i]-360)-(previous[i]-360))/step[i])
y = ((current[i]-(previous[i]+360))/step[i])
z = ((current[i]-(previous[i]-360))/step[i])
switch (Math.min(Math.abs(r),Math.abs(s),Math.abs(t),Math.abs(u),Math.abs(v),Math.abs(w),Math.abs(x),Math.abs(y),Math.abs(z))) {
case Math.abs(r):
output.push(r);
break;
case Math.abs(s):
output.push(s);
break;
case Math.abs(t):
output.push(t);
break;
case Math.abs(u):
output.push(u);
break;
case Math.abs(v):
output.push(v);
break;
case Math.abs(w):
output.push(w);
break;
case Math.abs(x):
output.push(x);
break;
case Math.abs(y):
output.push(y);
break;
case Math.abs(z):
output.push(z);
break;
}
}
return output;
}
答案 0 :(得分:0)
在我看来,你的引用错误可能与Java的ArrayIndexOutOfBounds错误相当。我试着改变
var points = step.length;
到
var points = step.length-1;
并查看是否可以解决您的问题,因为大多数“长度”参数是元素的数量(即最大引用+1)。你可能只是引用了“最后一点”,它不存在,因为它在数组之外。