Wednesday, September 3, 2014

run matlab function using command line

First, you need a matlab_batcher.sh file:

 matlab_exec=matlab  
 X="${1}(${2})"  
 echo ${X} > matlab_command_${2}.m  
 cat matlab_command_${2}.m  
 ${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command_${2}.m  
 rm matlab_command_${2}.m  

___________

Then for any matlab function you wanna run, using the following command (suppose the name of the function is smallrefine).

 ./matlab_batcher.sh smallrefine \'$lasercamclean_p_clean\',\'$raytraceclean_p_clean\',\'$planes_trans_mat\',\'$plane_refine_mat\'  

Pay attention to how we pass multiple string arguments to the matlab function.

No comments:

Post a Comment