GUI developed in Matalb 2013b behaving weirdly in Matlab 2015a
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (1)
Mike Garrity
le 4 Mai 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')
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!