Waitbar in horizontal steps, matlab

I am trying to change this code

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

for i=1:10, % computation here %  waitbar(i/10) end
close(h)

How can I divide waitbar into 10 steps. I mean, it should look like

-------------------
| | | | | | | | | |
-------------------
+3
source share
4 answers

The following code will allow you to add vertical lines to WAITBAR :

hWait = waitbar(0,'Progress');  %# Create the waitbar and return its handle
hAxes = get(hWait,'Children');  %# Get the axes object of the waitbar figure
xLimit = get(hAxes,'XLim');     %# Get the x-axis limits
yLimit = get(hAxes,'YLim');     %# Get the y-axis limits
xData = repmat(linspace(xLimit(1),xLimit(2),11),2,1);  %# X data for lines
yData = repmat(yLimit(:),1,11);                        %# Y data for lines
hLine = line(xData,yData,'Parent',hAxes,...  %# Plot the lines on the axes...
             'Color','k',...                 %#   ... in black...
             'HandleVisibility','off');      %#   ... and hide the handles

After executing the above code, and then execute waitbar(0.35,hWait);, you will see a figure similar to this:

enter image description here

. ( , , ) , . , WAITBAR , . , , MathWorks File Exchange, , , , - ya.;)

+5

Yo . :

h = waitbar(0, 'Please wait...');
for step=1:10
    waitbar(0, h, ['Step ' num2str(step) '/10 - Please wait...']);
    for i=1:100
        % Work...
        waitbar(i/100, h);
    end
end
+2

, , , , , :

h = waitbar(0,'Please wait...0% complete');
for i = 1:10
    % Computation here
    waitbar(i/10, h, sprintf('Please wait...%d%% complete',100*(i/10)));
end
close(h);
+1

Since waitbarthis is a built-in function with low flexibility, I think there is no easy way to make you look the way you want. If that really matters, you can draw a standby bar in several run modes and save it as an image. then you can upload the images in a simple gui that looks like something !;)

0
source

All Articles