second commit: matlab framework done, need more experiment and debug.