I have a standalone app in matlab. It gets a file name as an input and need to run this file. The file is on the same path as the standalone app.
thx, Mike.
I have a standalone app in matlab. It gets a file name as an input and need to run this file. The file is on the same path as the standalone app.
thx, Mike.
You can use the -a
option to compile additional files.
For instance, with this command you'll be able to call any .m file in your current directory from your standalone application:
mcc -m myscript.m -a *.m
It sounds like you're looking for the SYSTEM function. You can pass it any variable as a string:
s = 'ls'; % use 'ls' for Mac/Unix, 'dir' for Windows
[status, result] = system(s);
Here status
is the OS status code (0 means the program exited without error), and result
is the output of the program:
>> status
status =
0
>> result
result =
total 928
-rw-r--r-- 1 stew stew 0 Jul 24 2009 PROJECT_BASE
drwxr-xr-x 48 stew stew 1632 Mar 17 2011 analysis
-rw-r--r-- 1 stew stew 1944 Oct 4 2010 diff1
drwxr-xr-x 29 stew stew 986 Sep 24 2011 matlab
drwxr-xr-x 11 stew stew 374 Aug 5 2009 matlab_old
-rw-r--r-- 1 stew stew 62525 Jul 6 2010 nms.mat
-rw-r--r-- 1 stew stew 111423 Jul 7 2010 nms1.mat
drwxr-xr-x 52 stew stew 1768 Mar 2 2010 p60_analysis
drwxr-xr-x 4 stew stew 136 Mar 26 23:08 sims
-rw-r--r-- 1 stew stew 2212 Jan 29 2010 startup.m
-rw-r--r-- 1 stew stew 264635 Jun 13 18:22 test.bundle
-rw-r--r-- 1 stew stew 128 Sep 24 2010 testlatt.m
-rw-r--r-- 1 stew stew 4618 Jun 15 2011 tt-conn-ERRSTATE.mat
-rw-r--r-- 1 stew stew 6221 Jun 13 17:50
update_2012_June_13.bundle
drwxr-xr-x 4 stew stew 136 Jun 13 18:28 videos
NB: If the program is not on your executable path, you may need to specify its absolute path:
s = '/usr/bin/ls';
[status, result] = system(s);
I think I asked exactly a similar question and could not get an answear.
Is it possible to execute compiled code both within and out of MATLAB environment?
I believe it is not possible as Mathworks doesn't want you to distribute a free Matlab interpreter. I wonder if one can compile two set of M files separately and run the second from the first as a workaround.