Matlab水平步中的Waitbar [英] Waitbar in horizontal steps, matlab

查看:72
本文介绍了Matlab水平步中的Waitbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改此代码

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

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

如何将服务栏分为10个步骤.我的意思是它应该像

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

-------------------
| | | | | | | | | |
-------------------

推荐答案

以下代码将使您可以在

The following code will allow you to add vertical lines to your 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

运行上面的代码然后执行waitbar(0.35,hWait);之后,您将看到如下图:

After running the above code and then doing waitbar(0.35,hWait);, you will see a figure like this:

注意:情节中的黑线(我添加的垂直线进度条周围已经存在的框)将间歇地显示在红色上方或下方进度条在更新时.这似乎是一个现有的错误,具有 WAITBAR 的行为,我知道尚未找到解决方法来更正它.但是,可以在 MathWorks文件中找到很多替代方法Exchange ,所以我肯定会检查一下内置函数是否对您没有帮助. ;)

NOTE: The black lines in the plot (both the vertical lines I added and the already existing box around the progress bar) will intermittently appear above or below the red progress bar when it is updated. This seems like an existing bug with how WAITBAR behaves, and I have yet to find a workaround to correct it. However, there are quite a number of alternatives that can be found on the MathWorks File Exchange, so I'd certainly check those out if the built-in function doesn't do it for ya. ;)

这篇关于Matlab水平步中的Waitbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆