Opening Multiple Gui Problem
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have finished a gui project. It has two button. One of them to get excel file the other one is for to calculation. When i push the second button five more interface open on the background. What is the main reason of this and how can I solve it?
댓글 수: 3
Image Analyst
2020년 3월 1일
Attach the m-file and .fig file with the paper clip icon so we can actually run it ourselves.
채택된 답변
Thiago Henrique Gomes Lobato
2020년 3월 1일
When you do
save CVD
save PVD
...
you're actually saving your whole workspace, and thus later when you load it, you, at the same time, load many other GUI's and that's why you see other instances of the interface. You have here two options, either save only the variable, like:
save('CVD.mat','CVD')
Or, better, you use one of the standard methods to transfer data inside a GUI, as for example the handles structure (in this page there's a little tutorial http://matlab.izmiran.ru/help/techdoc/creating_guis/ch_program22.html). Basically you save all your variables in a structure called handles:
function callback1...
handles.CVD = 1; % Save variable in handles
guidata(hObject,handles); % tell the GUI to "update" the handles variable so other callback can see it
end
function callback2...
CVD = handles.CVD; % if you do first callback1 handles.CVD will now be 1
end
댓글 수: 3
Thiago Henrique Gomes Lobato
2020년 3월 2일
For matlab there's absolutely no difference between KontrolVeri and CVD in respect to save the variable/pass to the structure, so when you write
save KontrolVeri
you still save the interface within. In your code there's also no variable named 'ShutterDizi', only ShutterDizisi, which is defined at the VeriSec_Callback and will not be calleble in any other callback of your interface unless you save it somehow, as for example with the handles approach.
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!