Matlab implementation of ECC