Matlab executables, passing variable -


how use deploytool executable file .m function , use it?

say, have .m names foo, here code:

function product = foo(array_a,array_b) product = array_a.*array_b end 

now use deploytool generate foo.exe, how can use same workspace vars, aka array_a , array_b?

regards

i got code work supplying executable file variables.

i first ran mbuild -setup. have file, called foo2.m:

function product = foo(array_a,array_b) if ischar(array_a) array_a = str2num(array_a); end if ischar(array_b) array_b = str2num(array_b); end  product = array_a.*array_b end 

the difference ensured input processed numbers, not strings. then, compile:

mcc -mv -r -singlecompthread -n -p optim -p stats foo2.m 

(a explanation of command here: mcc example. used link me working.)

then, execute function.

./run_foo2.sh /usr/local/matlab/r2011a/ 1 2 

....

product =  2 

make sure specify location of compiler libraries first argument, array_a , array_b 2nd , 3rd arguments.

i first got error when tried run executable: error while loading shared libraries: libmwmclmcrrt.so.7.15: cannot open shared object file. fixed finding library file path (using find . -name "libmwmclmcrrt.so*"). corrected library path supplying first argument when called executable.


Comments