bar graph

Hello,
I am using a bar graph as a type of timer that shows how long is left on a running program. In the actual code, n will equal a variable
n=runningtime
for the below example, I just used the number 4
n=4;
for i=1:n;
pause(1);
i;
bar(i);
axis([0.9 1.1 0 n]);
hold;
end;
pause(1);
close
When I run this code, I get: Current plot held, Current plot released, Current plot held, Current plot released, etc, etc, depending on how many times it runs, based on the number that n equals. My question is how to stop this from displaying in the command window?

回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 3 月 22 日

0 投票

remove the
hold;
and put
hold on
before your code
Here's a better way to do the same thing
h = waitbar(0,'Please wait...');
for i=1:4
waitbar(i/4)
pause(1)
end
close(h)
Matt Tearle
Matt Tearle 2011 年 3 月 22 日

0 投票

Rather than use hold, why not do
h = bar(1);
axis(...)
outside the loop, then in the loop do
set(h,'YData',i)

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

質問済み:

2011 年 3 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by