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

Geoff Hayes
Geoff Hayes 2014년 7월 16일
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 2014년 7월 17일
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

댓글을 달려면 로그인하십시오.

 채택된 답변

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2014년 7월 17일

2 개 추천

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

aya
aya 2014년 7월 17일
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 2014년 7월 17일
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 2014년 7월 17일
sorry I did not understand you but I have the tag text18 with its create function
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2014년 7월 18일
편집: Alfonso Nieto-Castanon 2014년 7월 18일
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 2014년 7월 18일
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 2014년 7월 18일
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 2014년 7월 18일
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 2014년 7월 18일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

질문:

aya
2014년 7월 16일

댓글:

aya
2014년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by