matlab 进度条/waitbar 显示运行进度
當運行大程序,需要跑大量數據的時候,使用進度條可以看到程序究竟運行到什么地方了,哈哈,要不干等著難受(╯﹏╰)……
waitbar的作用是打開或者更新進度條。
1 語法結構
(1.1) h = waitbar(x,‘message’)
x表示進度條的比例長度,必須為0到1之間的數,message是在進度條上顯示的信息
(1.2) waitbar(x,‘message’,‘CreateCancelBtn’,‘button_callback’)%
通過制定CANCEL按鍵來終止程序運行。
(1.3) waitbar(x,‘message’,property_name,property_value,…)
(1.4) waitbar(x)
(1.5) waitbar(x,h)
(1.6) waitbar(x,h,‘updated message’)
通過(1.6)可以不斷更新進度條上的信息,用來顯示程序運行的進度。
(2) 結束時可以使用delete(h)或close(h)關閉它。
h=waitbar(0,'please wait'); for i=1:1000%computation here%waitbar(i/1000,h) end delete(h);如果要用數字顯示運行進度,
h=waitbar(0,'please wait');for i=1:1000%computation here%str=['運行中...',num2str(i/1000*100),'%'];waitbar(i/1000,h,str) end delete(h);例1:
h = waitbar(0,'Simulation inprocess'); for i=1:1000s=sprintf('Simulation in process:%d',ceil(i/10));waitbar(i/1000,h,[s '%']); end 或 h = waitbar(0,'Simulation inprocess'); for i=1:1000s=['Simulation in process:' num2str(ceil(i/10)) '%'];waitbar(i/1000,h,s); end仿真圖:
2 給waitbar添加標題
h = waitbar(0,'1','name','Simulation'); for i=1:1000s=sprintf('Simulation in process:%d',ceil(i/10));waitbar(i/1000,h,[s '%']); end仿真圖:
————————————————
原文鏈接:https://blog.csdn.net/MichaelPixer/article/details/55048754
http://blog.sina.com.cn/s/blog_acbf9f980102wma0.html
http://blog.sina.com.cn/s/blog_b2eaf2760101dyjn.html
總結
以上是生活随笔為你收集整理的matlab 进度条/waitbar 显示运行进度的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux查看当前用户权限(linux查
- 下一篇: 安卓微信文件夹储存在什么位置(安卓 微信