我有一个矩阵比率:= [undef; undef; 4]。
Local i
Local ratiotest
for i,1,rowDim(ratiotest),1
if ratiotest[i] = "undef" Then
∞→ratiotest[i]
end if
endfor
但我得到"Error: Variable is not defined"
有没有检测到未定义的变量?我在代码中遗漏了什么?
答案 0 :(得分:2)
使用构造IfFn
。如果是,第四个参数将被返回
第一个参数未定义。因此
IfFn(x,false, false, true)
仅在x未定义时才为真。
答案 1 :(得分:0)
有同样的问题和soegaard的解决方案无法正常工作。我唯一能做的就是将表达式转换为字符串并测试它是否为" undef"。这段代码将返回list2,其中list1的undef元素被替换为0。
for i1,1,dim(list1)
list_str:=string(list1[i1])
list2[i1]:=iffn(list_str="undef",0,list1[i1])
endfor