开发者

What is the basic idea behind programming a progress/status bar in MATLAB?

I have a MATLAB GUI I am working on and I would like to make a progress or status bar to show the user how long a certain script will take to run 开发者_JS百科or where it is running relative to when it will finish.

I am new to this GUI thing, anyone have any ideas on how this could be done?

I dont understand any of the examples (aka don;t know how to add to my code) on MATLAB's file exchange.

Thanks,

ME


The simplest answer is just to call waitbar. It is already in matlab, and will pop up a figure with a status bar that grows as you progress.

Of course, you can also download one of the many tools on the FEX, all subtle variations on waitbar. Or, you can use a text based bar, that shows up in the command window. Sometimes a text bar is what even I will choose.

If you really insist on programming your own tool that shows up in a figure window, it is not difficult. I did one of these recently, where the bar also changed color with progress of my algorithm. One might easily use the changing color to signify one piece of information, and the length of the bar as a second piece of information. So for example, an optimization might have the bar get longer with every iteration, and change color from red to green as the objective itself grows smaller.

As I recall, I simply created a textbox in my window, with the string something like: 'I''m thinking, get some coffee while you wait.' I then made the box invisible until it was time to start processing. Now, at each iteration, change the size of the box, and or the color that fills it. When done, make the box invisible again.


GUI's consists of a visual part and the related code. Visual GUI components like 'Buttons' for example, are tied to a 'callback function', the code part. When you press a 'Button' an associated 'callback function' is executed. Programming a GUI in matlab means filling in your code in theses callback functions.

When your GUI Elements are well arranged with GUIDE, the visual editor, callback dummies for all used elements are generated. All you have to do is fill in your code, implementing the desired behavior.

When you worked through some basic GUI tutorials it might be a doable task to add a progress bar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜