GUI push button problem

I have a project with GUI that contains two puss buttons the first called run when press on it it starts a simulation program that contains plotting of a figure I hide this figure because I want the second button to review the hidden figure by pressing it the second button called display network the problem is that when I press display network the action do not performed until the simulation program finishes How I make it possible to perform the action of second button while the action of the first button is still working

2 Comments

Why is it important to hide the plotting of a figure if you are just going to reveal the results with the press of the second button?
aya
aya on 17 Jul 2014
I am making a Wireless Sensor Network simulation in matlab that shows several results with different figures I want the user to be able to chose which result to see

Sign in to comment.

 Accepted Answer

You simply need to add the line:
drawnow;
to the code running the simulation steps so that Matlab flushes the event queue (and "reads-in" any potential buttonpress).

8 Comments

aya
aya on 17 Jul 2014
thank you very much it works but i have another question I am trying to do that set(handles.text18,'Visible','on') this should take action when i chose from a drop down menu but this error appears every time what should i do??
Attempt to reference field of non-structure array. Error in nahrain>popupmenu1_Callback (line 85) set(handles.text18,'Visible','on')
Evidently you don't have a control with the tag text18. Put a breakpoint there and type handles into the command window - do you see text18 listed?
aya
aya on 17 Jul 2014
sorry I did not understand you but I have the tag text18 with its create function
perhaps you are misinterpreting the scope of the variable handles. There are several ways to make some variable created during the GUI initialization to be available to the GUI callback functions. One possibility is to share the original workspace with the callback function, for example:
function mygui(...)
handles.text18 = uicontrol('style','text',...)
handles.popupmenu = uicontrol(...,'callback',@poupmenu1_Callback);
...
function poupmenu1_Callback(varargin)
set(handles.text18,'string','hello');
end
end
Would this work for you?
I don't think you do. And I don't think you took my suggestion to type handles at the breakpoint either or else you would see it's not there. So I'll have to do it myself. Please attach your m-file and fig-file.
aya
aya on 18 Jul 2014
thank you very much both I mange how to solve the problem but I have another question I used the command saveas to save a figure to be later shown when pressing on a button but this error keep appearing
Error using save Unable to write file pred_prey.fig: permission denied.
any suggestion
If you're using Windows, there are certain folders where it does not allow you to save anything, like under Program Files, etc. Make sure you're saving to a folder where you can save things. Can you, for example, paste a file in there with Windows Explorer without it asking you "if you're sure"?
aya
aya on 18 Jul 2014
yes I am using windows but I don't specify any folder to save the figure in it I think the default is the MATLAB file that is created when first installing matlab

Sign in to comment.

More Answers (0)

Categories

Asked:

aya
on 16 Jul 2014

Commented:

aya
on 18 Jul 2014

Community Treasure Hunt

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

Start Hunting!