How to display running FOR loop iterations (counts) on GUI window automatically

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

 Réponse acceptée

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 commentaires

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
% 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
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
Dishant Arora le 12 Mar 2014
Modifié(e) : Dishant Arora le 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
Thanks Dishant, I will follow this link...!!
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
Thanks Dishant, your help will be greatly appreciated.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Entering Commands dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by