Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 37403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:32:43+00:00 2026-05-10T14:32:43+00:00

I see in the MATLAB help ( matlab -h ) that I can use

  • 0

I see in the MATLAB help (matlab -h) that I can use the -r flag to specify an m-file to run. I notice when I do this, MATLAB seems to start the script, but immediately return. The script processes fine, but the main app has already returned.

Is there any way to get MATLAB to only return once the command is finished? If you’re calling it from a separate program it seems like it’s easier to wait on the process than to use a file or sockets to confirm completion.

To illustrate, here’s a sample function waitHello.m:

function waitHello     disp('Waiting...');     pause(3); %pauses 3 seconds     disp('Hello World');     quit; 

And I try to run this using:

matlab -nosplash -nodesktop -r waitHello 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:32:43+00:00Added an answer on May 10, 2026 at 2:32 pm

    Quick answer:

    matlab -wait -nosplash -nodesktop -r waitHello 

    In Matlab 7.1 (the version I have) there is an undocumented command line option -wait in matlab.bat. If it doesn’t work for your version, you could probably add it in. Here’s what I found. The command at the bottom that finally launches matlab is (line 153):

    start 'MATLAB' %START_WAIT% '%MATLAB_BIN_DIR%\%MATLAB_ARCH%\matlab' %MATLAB_ARGS% 

    The relevant syntax of the start command (see ‘help start’ in cmd.exe) in this case is:

    start ['window title'] [/wait] myprogram.exe args ... 

    A bit higher, among all of the documented command line options, I found (line 60):

    ) else if (%opt%) == (-wait) (   set START_WAIT=/wait ) else ( 

    So specifying -wait should do what you want, as long as you’re also exiting matlab from your script (otherwise it will wait for you to terminate it interactively).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I start a MATLAB script and realize too late that it is going
Does anybody know how I can see the code of a matlab p-code file?
I'm plotting on top of an image in Matlab. Sometimes, I can't see what's
Would somebody help me please in this question. I'm new in Matlab... And it's
How can I see a list of what global variables are defined in MATLAB?
In ordinary class methods I can supply content for the help command in MATLAB.
How can I write Erlang B Formula as you see below in MATLAB? I
Here is a simple matlab script to read a csv file, and generate a
I'm learning Matlab and I see a line that I don't understand: A=[x; y']
In a matlab script, I'm generating a latex table. A part of that table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.