MATLAB ECC implementation