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!