Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Closing DOS window from matlab

Subject: Closing DOS window from matlab

From: Quentin

Date: 10 Dec, 2008 05:24:02

Message: 1 of 2

Hello all,

I have a quick question and my internet searches haven't quite gotten me a solution yet. Seems like a real common problem.

I am running a .exe file within a for loop in matlab. I need matlab to start and stop this file each loop iteration. I can get matlab to run the code using !program.exe & and then have matlab close the program by sending a command to that programs via dde. The only problem with this is that the & command (which I need to give matlab access to the dde library) opens up a DOS window with each loop iteration. I need to do many loops so I would like a way to automatically close these windows within matlab. Anyone have an .m file or know of any commands I can use?

Thanks a ton!

Subject: Closing DOS window from matlab

From: Jeroen

Date: 6 Mar, 2009 15:53:01

Message: 2 of 2

Hi Quentin,

Just came across a similar issue. I solved it using a trick; made a .bat file which contains the following two lines:


If you call the .bat file from Matlab in the same way you would start a normal executable, the .exe will be run in a dos window, which should now close after the .exe has finished. I have no experience with the dde library, however.


Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us