added matlab generating code