Opening Multiple Gui Problem
1 view (last 30 days)
Show older comments
Onur ALPAY
on 1 Mar 2020
Commented: Onur ALPAY
on 4 Mar 2020
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 Comments
Image Analyst
on 1 Mar 2020
Attach the m-file and .fig file with the paper clip icon so we can actually run it ourselves.
Accepted Answer
Thiago Henrique Gomes Lobato
on 1 Mar 2020
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 Comments
Thiago Henrique Gomes Lobato
on 2 Mar 2020
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.
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!