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

  • Home
  • SEARCH
  • 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 1021209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:16:35+00:00 2026-05-16T11:16:35+00:00

I want to have a waitbar for an operation that takes quite a while.

  • 0

I want to have a waitbar for an operation that takes quite a while. Here is my code:

h = waitbar(0,'Please wait...');

for i=1:counterend
    waitbar(i/waitbarcounter)
    Atemp    = At+i*step;
    handle   = @(M) 1/M^2*((2/(gamma+1))*(1+(gamma-1)*M^2/2))^((gamma+1)/(gamma-1))-(Atemp/At)^2;
    Mach     = fzero(handle, 5);
    Aplot(i) =  Atemp/At;
    Tplot(i) = Tc / (1+(gamma-1)*Mach^2/2);
    Mplot(i) = Mach;
    plot(Aplot, Tplot)
end

close(h) 

The error Matlab gives is:

??? Error using ==> waitbar at 249
Improper arguments for waitbar

After investigation, I am sure that this error must occur because of the sorrounding code in the loop.

Note: The loop works fine without the waitbar.

  • 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-16T11:16:36+00:00Added an answer on May 16, 2026 at 11:16 am

    Running

    counterend = 10000;
    >> h = waitbar(0,'Please wait...');
    
    for i=1:counterend
        waitbar(i/counterend)
    end
    
    close(h);
    

    Works as expected on 2007a / Windows XP.

    On a side note, it would help knowing what countered is defined as. Something quick to check would be to ensure that you are not passing it a CELL.

    Running

    counterend = {10000};
    h = waitbar(0,'Please wait...');
    
    for i=1:counterend
        waitbar(i/counterend)
    end
    
    close(h);
    

    Yields a different error (see below) in 2007a, but this error message may have changed in 2008.

    ??? Undefined function or method
    ‘_colonobj’ for input arguments of
    type ‘cell’.

    My last bit of advice would be caution you on the use of waitbar for large arrays/data sets. While I think it is important to inform the user of the progress, to me there is also a concern for how much time is added to the loop. Working with arrays that have 100k+ entries, I became a religious user of the Profiler to see where the time was really being spent. I can tell you the time is not in the calculation of the i/X, it was all in updating the waitbar’s display. To soften the blow of the update/drawnow, I only updated the waitbar every 100 to 1000 entry which helped tremendously.

    EDIT: Updated response to match latest code

    I first started to attack this problem at the anonymous function, having problems with them in the past it’s a personal vendetta of mine. When looking into the function I found that you are using gamma, do you have this defined as a constant (constant to the loop / function)? The reason I ask is that ‘gamma’ is a Matlab function and was giving me errors when trying to run your function by itself. Below I have modified you code slightly and this does run fine here. If any of the assumptions I have made are wrong please let me know.
    In addition, if you did intend to use the gamma function, your function is missing any arguments to it. Hope this helps!

    clc
    h = waitbar(0,'Please wait...');
    counterend = 1000;
    waitbarcounter = counterend;
    g_amma = 7;
    At = 34;
    step = 2;
    Tc = 42;
    
    for i=1:counterend
        waitbar(i/waitbarcounter)
        Atemp    = At+i*step;
        handle   = @(M) 1/M^2*((2/(g_amma+1))*(1+(g_amma-1)*M^2/2))^((g_amma+1)/(g_amma-1))-(Atemp/At)^2;
        Mach     = fzero(handle, 5);
        Aplot(i) =  Atemp/At;
        Tplot(i) = Tc / (1+(g_amma-1)*Mach^2/2);
        Mplot(i) = Mach;
        plot(Aplot, Tplot)
    end
    
    close(h) 
    

    Regards,

    Adam

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

Sidebar

Related Questions

I want to have an insert tab button for my UITextView so that users
If I have output from two sources that I want to put together on
Here is my problem: I want have my qmake script detect my opencv version
I have simllar question like here: static-method-invocation , but in PHP. Simply, I want
I want to have a custom cursor while moused over the Google Maps component
I want have a query with a column that is a hardcoded value not
I want have a single database that uses InnoDB tables instead of myISAM tables
I want have a table in my view that is going to put 3
I want have link on click of that link a javascript function is called.
i want have an image and i want to set it as a background

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.