GUI developed in Matalb 2013b behaving weirdly in Matlab 2015a
이전 댓글 표시
I created a GUI with few buttons in it. I'm storing workspace variables in a .mat file for a callback and loading the same mat file while calling another callback
func1_callback
{
x=1;
y=2;
set_param(handles, '<property>', 'value');
save xyz.mat
}
func2_callback
{
load xyz.mat
...
...
}
The callbacks are associated to two different buttons on the GUI. When I click on second button a separate instance of GUI opens up.. this happens for every callback/function where i'm loading mat file
Any solutions/suggestions to get rid of this issue?
채택된 답변
추가 답변 (1개)
Mike Garrity
2015년 5월 4일
My guess would be that you have handles to graphics objects in your workspace when you save the MAT file. Consider the following example:
h = plot(1:10)
save my_file.mat
At this point, my_file.mat contains h. In earlier versions of MATLAB, h was just a double with a funny value like 156.0025. But starting in 14b, it's actually the handle of the Line object that plot created. When you load that MAT file back into MATLAB, you're going to get that Line object back.
In your case, you probably want to either use a form of save where you list the variables you want to save:
save('xyz.mat','x','y')
Or call clear before save to get rid of anything you don't want saved in the file:
clear('h')
save('xyz.mat')
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!