for i = 1:n
ymin = realmax;
ymax = 0;
for j = 1:4 % each perceptron
for k = 1:40
yval = waves0(k,j,i);
if(yval > ymax) ymax = yval;
if(yval < ymin) ymin = yval;
end
end
end
我试图找到最小值和最大值,但是当我运行该函数时,我得到了:
parse error near line 20 of file /Volumes/FDISK/mlr/YvalDistance.m
syntax error
parse error near line 20 of file /Volumes/FDISK/mlr/YvalDistance.m
syntax error
parse error near line 20 of file /Volumes/FDISK/mlr/YvalDistance.m
syntax error
parse error near line 20 of file /Volumes/FDISK/mlr/YvalDistance.m
syntax error
第20行是函数的最后一行,为空。
如果我发表评论if(yval < ymin) ymin = yval;
,我就不会再收到解析错误了。什么了?
octave:39> version
ans = 3.2.4
答案 0 :(得分:0)
尝试一下
的内容if (yval > ymax)
ymax = yval;
else if (yval < ymin)
ymin = yval;
endif
我猜这是因为你从未用endif
关闭你的if答案 1 :(得分:0)
为什么不摆脱语法错误和加速代码:
yvals = zeros(1,4*40);
for j = 1:4
for k = 1:40
yvals((j*4)+k) = waves0(k,j,i);
end
end
ymax = max(yvals);
ymin = min(yvals);