在Matlab中获取waitbar的值 [英] Get waitbar value in Matlab

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

问题描述

如何在Matlab中获取等待栏的值?也就是说,要知道是50%填充还是75%填充,依此类推.我猜这可以使用创建进度条时返回的句柄(h)来完成:

How could I get the value of a waitbar in Matlab? That is, to know if 50% filled, 75%, and so on. I guess it could be done using the handle (h) returned when the progress bar is created:

> h = waitbar(0,'Please Wait');

我想这是一个非常简单的问题,但是,我一直在为我努力,但没有解决它.谢谢

I guess this is a pretty simple question, however, I have been trying for I while without solving it. Thanks

推荐答案

有两种方法.

首先,从文档中获取waitbar():

First, from the documentation for waitbar():

waitbar(x)随后调用waitbar(x)延长了条形的长度 到新位置x. x的连续值通常会增加.如果他们 减少,等待栏反向运行.

waitbar(x) subsequent callsto waitbar(x) extend the length of the bar to thenew position x. Successive values of x normallyincrease. If they decrease, the wait bar runs in reverse.

waitbar(x,h)将等待条h中条的长度扩展到 newposition x.

waitbar(x,h) extends thelength of the bar in the wait bar h to the newposition x.

waitbar(x,h,'updated message')更新等待栏中的消息文本 图,除了将小数长度设置为x.

waitbar(x,h,'updated message') updates the message text in the waitbar figure,in addition to setting the fractional length to x.

其中x是介于0和1之间的值.

Where x is a value between 0 and 1.

第二,更笼统:

get()set()将允许您获取和更改 MATLAB对象属性.执行get(h)将返回可以处理和修改的对象句柄h所有已记录属性的列表.

get() and set() will allow you to obtain and change MATLAB object properties. Executing get(h) will return a list of all the documented properties of object handle h you can address and modify.

对于您不完全了解对象句柄结构的GUI,可能不容易看出您需要调整哪个对象的属性才能获得所需的结果.在waitbar()的情况下,从我的快速浏览中可以看出,您需要向下几个子图层才能进入可以用set()修改的绘制的条形部分.鉴于waitbar()的功能已足够,这似乎比值得付出的努力还要多.

For GUIs where you don't have a complete knowledge of the object handle structure it may not be readily apparent which object's property you need to adjust in order to achieve the results you want. In the case of waitbar(), it appears from my quick poking around that you need to go down a few child layers to get to the plotted bar portion that you can modify with set(). This seems like far more effort than it's worth given that the functionality of waitbar() is sufficient.

就从预先存在的等待栏中找出值是什么,这是解决问题的一种很round回的方法(为什么不仅仅看生成它的代码?):

As far as finding out what the value is from a preexisting waitbar, which is a pretty roundabout way to go about it (why not just look at the code that's generating it?):

h = waitbar(0,'Please Wait');
level1 = get(h,'Children');
level2 = get(level1,'Children');
test = get(level2(2),'xdata');

返回:

test = [0 0 0 0]

执行中:

waitbar(0.5,h)   
test = get(level2(2),'xdata');

返回:

test = [0 50 50 0]

我不相信修改栏以更新栏的正确字段(修改栏并强制使用drawnow进行更新似乎没有影响),但是它回答了这个问题.

Which I don't believe is the correct field to modify to update the bar (modifying it and forcing an update with drawnow doesn't seem to have an affect), but it answers the question.

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

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