fprintf to the command line

1 回表示 (過去 30 日間)
Matlab2010
Matlab2010 2012 年 5 月 2 日
Hello.
having some problems getting to grips with fprintf.m.
please can you help?
If I run:
function myFunc
b=10;
for i=1:b
fprintf('%c%c%c%c%c%c%c%c%2d of 10',8,8,8,8,8,8,8,8,i);
pause(0.1);
end
fprintf('\n');
end
i see a nice output on the command line. great.
what I would like to produce is a progress bar. I try:
function myFunc2()
b= 10;
vec = repmat(' ', [1, b]);
vecA = ['[' vec ']'];
var = repmat('%s', [1, b+2]);
for i=1:b
vecA(i+1) = '#';
fprintf(var,vecA);
pause(0.1);
end
fprintf('\n');
end
and you see that I do not get the nice updating output on the same line, but an output which has been overwritten.
Clearly I am using fprintf wrongly. can you help? thanks

採用された回答

per isakson
per isakson 2012 年 5 月 2 日
In FEX you will find Text progress bar and other text based progress bars.
  1 件のコメント
Matlab2010
Matlab2010 2012 年 5 月 2 日
that contains the fprint examples I needed. thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMuPAD についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by