Scilab syntax error: unexpected endfunction, expecting end

Scilab syntax error: unexpected endfunction, expecting end

我是 scilab 的新手,写一个简单的函数会抛出一个语法错误,这对我一点帮助都没有。

syntax error: unexpected endfunction, expecting end

有人可以指出错误,我觉得一切都很好。

我正在使用 .sci 扩展名保存。

function y = bin2SignDec(bin)
    // Determines the signal of the binary number
    if part(bin, 1:1) == '0' then
        signal = 1;
    else
        signal = -1;

    // remove the signal bit from the string
    uBin = part(bin, 2:length(bin));

    // find the position of the decimal point and split the value in two variables
    pointIndex = strindex(uBin, '.');
    integerStr  = part(uBin, 1:(pointIndex-1));
    fractionStr = part(uBin, (pointIndex+1):length(uBin));

    // convert integer part to decimal
    integer = bin2dec(integerStr);

    // convert fraction part to integer
    fraction = 0;
    for i = 1:length(fractionStr)
        fraction = fraction + strtod(part(fractionStr, i:i)) * 2^(-i);
    end

    // return
    y = integer + fraction;

endfunction

if then else 构造后缺少 end