From: John on
Hi all,

I want to execute a simple M script from the command line in a .BAT file. Right now I can open the .m file but then I have to hit "F5" to run and then close the editor. It's fine if Matlab is already up and running in a window.

Any ideas?

Thank you!

- John
From: Walter Roberson on
John wrote:

> I want to execute a simple M script from the command line in a .BAT
> file. Right now I can open the .m file but then I have to hit "F5" to
> run and then close the editor. It's fine if Matlab is already up and
> running in a window.

Under Unix type systems, you would use the '-r' flag followed by the quoted
text of the command to execute, such as

matlab -r 'doanalysis(5);quit'

I do not run the Windows version so I do not recall whether under Windows the
flag is still -r or if it changes to /R ... I think it remains -r .
From: John on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hluhoq$bqf$2(a)canopus.cc.umanitoba.ca>...
> John wrote:
>
> > I want to execute a simple M script from the command line in a .BAT
> > file. Right now I can open the .m file but then I have to hit "F5" to
> > run and then close the editor. It's fine if Matlab is already up and
> > running in a window.
>
> Under Unix type systems, you would use the '-r' flag followed by the quoted
> text of the command to execute, such as
>
> matlab -r 'doanalysis(5);quit'
>
> I do not run the Windows version so I do not recall whether under Windows the
> flag is still -r or if it changes to /R ... I think it remains -r .

Thank you Walter,

This does work (without the single quotes in dos). However it opens a new copy of Matlab each time I run it which is slow. I'd really like to run in my already-open Matlab session. Any ideas there?
From: Jos (10584) on
"John " <John(a)Twisthink.com> wrote in message <hlu9vn$o9j$1(a)fred.mathworks.com>...
> Hi all,
>
> I want to execute a simple M script from the command line in a .BAT file. Right now I can open the .m file but then I have to hit "F5" to run and then close the editor. It's fine if Matlab is already up and running in a window.
>
> Any ideas?
>
> Thank you!
>
> - John

Instead of a bat-file calling matlab why not let matlab call the batch commands, using SYSTEM or DOS, and its own m-files?

hth
Jos
From: John on
> Instead of a bat-file calling matlab why not let matlab call the batch commands, using SYSTEM or DOS, and its own m-files?
>
> hth
> Jos

I'm trying to run a series of Matlab demonstration files from a presentation. Currently my best solution is to simply run the .m file directly, which opens the editor and I can just hit F5 to run and close the editor when it's finished.

matlab -r fileName();exit

Is good too, but slower since Matlab has to open and close each time it's called. So, I'm looking for the Holy Grail here.