added matlab code, and updating c code