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 6091657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:21:11+00:00 2026-05-23T12:21:11+00:00

I know that there is the possibility of Matlab of pausing a Matlab function

  • 0

I know that there is the possibility of Matlab of pausing a Matlab function or script by using input() thus when I have a for-loop and want to pause it every iteration:

for i = 1:N
  reply = input(sprintf('Pausing in iteration %d! Continue with Enter!', i), 's');

  % Calculations
end

but how to get the following working: Usually it runs without pausing (as if the input() wouldn’t be there) but when the user does something (perhaps press a key, a button, or something similar in matlab), the script/function does PAUSE each iteration until the the user does it again, thus something like this. E.g. let’s say there is the possibility of matlab to toggle a variable whenh pressing a certain hotkey combination, e.h. Ctrl+Alt+A toggles the variable myToggle between 0 and 1 I could easily do:

for i = 1:N
  if(myToggle == 1)
    reply = input(sprintf('Pausing in iteration %d! Continue with Enter!', i), 's');
  end 

  % Calculations
end

Thanks in advance!

EDIT: Just found ONE possible solution here: Function to ask a MATLAB program to wait for an event before continuing execution I could create a file on the beginning of my function/script and pause on the next iteration when it doesn’t exist anymore. But that would require the user to rename the file which isn’t quite that ‘comfortable’… Any other ideas? 🙂

  • 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. Editorial Team
    Editorial Team
    2026-05-23T12:21:11+00:00Added an answer on May 23, 2026 at 12:21 pm

    You can use a simple GUI with a button; once pressed the execution halts on the next iteration.

    function testGUI()
        doPause = false;
        figure('menu','none', 'Position',[400 400 150 30])
        hb = uicontrol('Style','pushbutton', 'String','Pause', ...
            'Callback',@buttonCallback, 'Unit','Normalized', 'Position',[0 0 1 1]);
        %drawnow
    
        while ishandle(hb)
            %# check if the user wants to pause
            if doPause
                pause()             %# pauses until user press any key
    
                %# reset
                doPause = false;
                if ishandle(hb), set(hb, 'Enable','on'), drawnow, end
            end
    
            %# Calculations
            disp(rand), pause(.1)
    
            %# keep the GUI responsive
            drawnow
        end
    
        %# callback function for the button
        function buttonCallback(hObj,ev)
            doPause = true;
            set(hObj, 'Enable','off')
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are some threads have a similar issue with this thread.
Is there any possibility to fit a curve to that histogram above in Matlab?
While I know that there is the possibility: >>> a = abc >>> result
I know that there is Monodroid for developing in C#.But does it give possibility
I know that there are lot's of questons on this, but all seem to
I know that there are others posts with solutions on the site but i
I know that there are currently questions on SO already pertaining to saving jQuery
I know that there are lots of examples out there on this, but they
I know that there can be multiple values for an email, but I'm not
I know that there are many Delphi database related questions available, but I'm considering

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.