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 Kommentare

Geoff Hayes
Geoff Hayes am 16 Jul. 2014
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 am 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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon am 17 Jul. 2014

2 Stimmen

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 Kommentare

aya
aya am 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')
Image Analyst
Image Analyst am 17 Jul. 2014
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 am 17 Jul. 2014
sorry I did not understand you but I have the tag text18 with its create function
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon am 18 Jul. 2014
Bearbeitet: Alfonso Nieto-Castanon am 18 Jul. 2014
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?
Image Analyst
Image Analyst am 18 Jul. 2014
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 am 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
Image Analyst
Image Analyst am 18 Jul. 2014
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 am 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by