Just copy and add the next function in your Scilab editor:
function H = hadamard(n)
if( ~n | ~( log2(n) == int(log2(n)) ) ) then
msg = gettext("%s: n must be a power of 2\n");
error(msprintf(msg, "Hadamard Error"));
end
if(n == 1) then
H = n;
else
H = hadamard(n*0.5).*.[1 1; 1 -1];
end
endfunction
H = hadamard(1);
H =
1.
H = hadamard(2);
H =
1. 1.
1. - 1.
H = hadamard(4);
H =
1. 1. 1. 1.
1. - 1. 1. - 1.
1. 1. - 1. - 1.
1. - 1. - 1. 1.
H = hadamard(5);
Hadamard Error: n must be a power of 2
at line 4 of function hadamard called by :
H = hadamard(5);