I'm new to scilab and writing a simple function throws a syntax error which isn't helping me at all.
syntax error: unexpected endfunction, expecting end
Someone can point me the error, everything seems fine to me.
I'm saving with .sci extension.
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