How to display running FOR loop iterations (counts) on GUI window automatically
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hell All,
I want to make a display button in my matlab GUI who can automatically show the running FOR loop iterations/ counts just like it shows in matlab workspace during programming running. e.g. 1,2,3...........200,....400....1000.....n-iterations
How to make such type of GUI DISPLAY window and what could be the script of this DISPLAY callback function?
Thank you very much in advance!
-- K.D.Singh
Accepted Answer
Dishant Arora
on 11 Mar 2014
h = figure;
set(h , 'Units' , 'Normalized' , 'position' , [0.4 0.4 0.2 0.2]);
h1 = uicontrol(h , 'style' , 'text' , 'Units' , 'Normalized'...
, 'position' , [0.4 0.4 0.2 0.2] , 'string' , 'Output');
for ii = 1:10
set(h1 , 'string' , num2str(ii));
pause(0.5)
drawnow;
end
7 Comments
Keshav Dev Singh
on 12 Mar 2014
Thanks Dishant,
Actually I want the same display window but it should be embedded on my main GUI window and whenever I click my RUN program button then that white embedded figure (h) inside my main GUI will display the number of iterations in running mode exactly same as it shows in my matlab workspace during code running. I don't want separate figure as your above code is doing. It should be a part of my main GUI window. Please also let me know how to make such "display" on my main GUI window and where I have to put the code which you will provide. I hope you got my question.
Thank you very much for your kindness,
--
K.D.Singh
Dishant Arora
on 12 Mar 2014
Edited: Dishant Arora
on 12 Mar 2014
% This should come under your gui opening function, Stores figure handle in root gui.
setappdata(0 , 'figureHandle' , handles.figure1);
% Your Script containing for loop
h = getappdata(0 , 'figureHandle');
h1 = uicontrol(h , 'style' , 'text' , 'Units' , 'Normalized'...
, 'position' , [0.4 0.4 0.2 0.2] , 'string' , 'Output');
for ii = 1:10
set(h1 , 'string' , ii);
pause(0.5)
drawnow;
end
Keshav Dev Singh
on 12 Mar 2014
Thank you very much Dishant it is working perfectly. May I know from where you studied the matlab GUI so deeply? Can you suggest any good book or web-link/ pdf to make a good command over GUI.
Sincerely,
--
K.D.Singh
Dishant Arora
on 12 Mar 2014
Edited: Dishant Arora
on 12 Mar 2014
This particular video How to pass data from one GUI to another in MATLAB covers some really important aspects of GUI building. Personally I'd say it's the best thing you can find on net to learn matlab GUI. And there are other good video tutorials on guide in the same blog under the guide category. That's all I followed to capture GUI concepts
Keshav Dev Singh
on 12 Mar 2014
Thanks Dishant, I will follow this link...!!
Image Analyst
on 12 Mar 2014
The key thing was the drawnow. Anytime your display doesn't update fast enough, insert a drawnow. Here's another link to help you learn MATLAB: http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab
And for image processing demos (though only a handful of over a hundred that I have), you can go here: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Keshav Dev Singh
on 18 Mar 2014
Thanks Dishant, your help will be greatly appreciated.
More Answers (0)
Categories
Find more on Entering Commands in Help Center and File Exchange
See Also
on 11 Mar 2014
on 18 Mar 2014
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)