GUI developed in Matalb 2013b behaving weirdly in Matlab 2015a
Show older comments
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?
Accepted Answer
More Answers (1)
Mike Garrity
on 4 May 2015
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')
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!