Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / MATLAB / July 2008



Tip: Looking for answers? Try searching our database.

Command line questions...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ray - 06 Jul 2008 21:02 GMT
Hello,

I'm just getting started with Matlab so I've got quite a
few questions, mostly regarding command line operation at
this point.  I realize there is a Matlab compiler but for
now I need to run the applications directly from their .m
files.

1.  I currently have a compiled Matlab application but I
need MRC v73 to run it.  Is MRC v73 available somewhere for
download?  There are plenty of v74s on the Web but I can't
find v73.  If I try to run the application using v74, it
errors out looking for v73 DLLs.  Just as a test, I tried
renaming all the v74 DLLs using the v73 names, but I didn't
really expect that to work, and it didn't.

2.  The .m files for the application I am developing is
spread across several subdirectories.  From within the
Matlab IDE itself I can simply add all these subdirectories
to the path and everything works fine.  However, when I
start a .m file from the command line, everything blows up
when a .m file in a different directory is needed.  How do
I specify an assortment of different search paths from the
command line?

3.  When I start a .m file by starting Matlab from the
command line, how do I get Matlab itself to terminate when
the execution of all the .m files terminates?

Thanks,
Ray
NZTideMan - 07 Jul 2008 00:42 GMT
> Hello,
>
[quoted text clipped - 27 lines]
> Thanks,
> Ray

I'm not sure what you mean by the "command line", but I'll assume that
you have a Matlab command window open and that you enter commands
after the >>.
1.  I don't know what MRCv73 is.
2.  You should set the path to all your directories using either
setpath or in the GUI in Files/Set Path, not the command line.
3.  Either exit or quit terminates Matlab.
Scott Hirsch - 07 Jul 2008 12:32 GMT
Ray -

Could you clarify what you mean by "Command Line"?  Are you
referring to the MATLAB Command Line, or a system prompt?
If you want to launch MATLAB and have it run specific files
from a system prompt, you can use the -r startup flag, e.g.

> matlab -r "mymfile"

The MCR (I assume this is what you are referring to) is an
execution engine only for applications compiled through the
MATLAB compiler.  You can't run arbitrary m-files against
it.  The only legitimate source of distribution of the MCR
is from a licensee of the Compiler - i.e., somebody who owns
the MATLAB compiler can give copies of the MCR to people who
want to run the applications they build with it.
Ray - 07 Jul 2008 17:26 GMT
"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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.