Added matlab support.
Modified some c and cpp code to help.