Launch
counterend = 10000; >> h = waitbar(0,'Please wait...'); for i=1:counterend waitbar(i/counterend) end close(h);
Works as expected in 2007a / Windows XP.
On the other hand, it will help to find out what occurs as indicated. Something quick to check would be to make sure that you are not passing CELL to it.
Launch
counterend = {10000}; h = waitbar(0,'Please wait...'); for i=1:counterend waitbar(i/counterend) end close(h);
Another error loses (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 tip will warn you about using the waitbar for large arrays / datasets. Although I think itβs important to keep the user informed about the progress, there is also a concern for me about how much time has been added to the loop. Working with arrays having 100k + entries, I became a religious Profiler user to find out where the time was really spent. I can say that the time is not in calculating i / X, it was all in updating the display of the standby panel. To mitigate the blow of the update / retraction, I only updated the message bar every 100-1000 entries, which helped a lot.
EDIT: Updated answer to match latest code
At first I started attacking this problem with anonymous functions, having problems with them in the past, this is a personal vendetta. When you studied the function, I found that you use the gamma, you define it as a constant (constant for the loop / function)? The reason I ask is because the "gamma" is a Matlab function and was giving me errors when trying to run your function on its own. Below I changed the code a bit, and everything works fine here. If any assumptions I made are wrong, please let me know. In addition, if you intended to use the gamma function, your function does not have any arguments. 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)
Hi,
Adam