How to run a .m (matlab) file through java and matlab control? -
How to run a .m (matlab) file through java and matlab control? -
i have 2 .m files. 1 function , other 1 (read.m) reads function , exports results excel file. have java programme makes changes .m files. after changes want automate execution/running of .m files. have downloaded matlabcontrol.jar , looking way utilize invoke , run read.m file reads function. can help me code? thanks
i have tried code not work.
public static void tomatlab() throws matlabconnectionexception, matlabinvocationexception { matlabproxyfactoryoptions options = new matlabproxyfactoryoptions.builder() .setusepreviouslycontrolledsession(true) .build(); matlabproxyfactory mill = new matlabproxyfactory(options); matlabproxy proxy = factory.getproxy(); proxy.eval("addpath('c:\\path_to_read.m')"); proxy.feval("read"); proxy.eval("rmpath('c:\\path_to_read.m')"); // close connection proxy.disconnect(); }
based on the official tutorial in wiki of project, seems quite straightforward start api.
the path-manipulation might bit tricky, give seek loading whole script string , passing eval (please note have no prior experience specific matlab library). done quite (with joining files.readalllines() example).
hope helps something.
java matlab execution
Comments
Post a Comment