"Scott Hirsch" <shirsch.nospam@mathworks.com> wrote in
message <g4suri$oi1$1@fred.mathworks.com>...
> Ray -
>
[quoted text clipped - 12 lines]
> the MATLAB compiler can give copies of the MCR to people who
> want to run the applications they build with it.
Hi Scott,
Yes, in retrospect I was very ambiguous. I'm referring to
the System Command Line (the DOS prompt, as it were).
To run a .m file function named FunctionName in a file by
the same name, I have gotten the following to work, as you
suggested:
matlab -nodesktop -nosplash -r FunctionName
However, the function I am starting needs 6 arguments, with
the first 3 being floating point numbers and the last 3
being strings. I've tried every weird permutation I can
think of but the values I put in just never get through:
matlab -nodesktop -nosplash -r FunctionName arg1 arg2 arg3
etc.
This part has me stumped. I tried also using variable
argument detection withing the .m file function, but I
haven't gotten that to work either. I finally resorted to
simply putting the arguments in a file, then letting the .m
function read them from there. That works, but what a
kluge!
Thanks,
Ray
Dmitry Savransky - 30 Jul 2008 15:30 GMT
The following is guaranteed to work on *nix systems, but I
have never tried running MATLAB from a command prompt in
windows, so take this with a grain of salt.
1. Getting the path right: You can use the Set Path GUI to
create the exact path you want, and then save the
'pathdef.m' file to the directory you will be starting
matlab from (you can also use the 'savepath' command).
Alternatively, you can start matlab with a path command:
matlab -r "path(path,'newdir')" or
matlab -r "addpath('dir1','dir2',...)"
I have actually aliased the 'matlab' command to something
like this on my system, so the path is set correctly no
matter what directory I start matlab from.
2. Running functions from the command line: The -r command
will execute whatever you give it, so you can do something like:
matlab -nojvm -nodesktop -r "sum([10,20,30])"
and get the proper output. I actually prefer your method
(writing a script wrapper to the function and just running
that) since MATLAB will only process the last -r command
given to it, ignoring any others (including ones that may
have been aliased). By using a script, you can set both the
path and all of your input function values much more easily.
Hope this helps.
"Ray " <RayMitchell@MeanOldTeacher.com> wrote in message
<g4tg2p$lps$1@fred.mathworks.com>...
> "Scott Hirsch" <shirsch.nospam@mathworks.com> wrote in
> message <g4suri$oi1$1@fred.mathworks.com>...
[quoted text clipped - 49 lines]
> Thanks,
> Ray