Why do I get "Warning: Cannot load an object of class 'UIControl'" and how can I fix it?

66 views (last 30 days)
I built a GUI that saves a .mat file before running a simulation. I can reload files I save without issue. But my colleague recently sent me one of these MAT files and when I tried to open it got the following:
Warning: Cannot load an object of class 'UIControl' Its class cannot be found.
We haven't encountered this issue before. But recently he upgraded to Matlab 2014b while I still have Matlab 2014a. He can load files I saved with no issue but I get this warning when I try to load files he saved.
After some preliminary research I think employing saveobj/loadobj may solve our problem. But I don't really understand their documentation or what the problem really is. So, I'm not sure how to use saveobj and loadobj.
Can anyone explain to me why I have this issue in the first place, what saveobj/loadobj do and how to solve the problem? Any help with those 3 questions would be greatly appreciated.
Thanks

Accepted Answer

Guillaume
Guillaume on 18 Jun 2015
You're seeing this error because of the changes to the graphics in R2014b. Graphics handles are no longer numbers but full-blown classes.
You can't use saveobj / loadobj to solve your problem unless what you're saving in your .mat file is your own custom class. They can only be used to change the save and load behaviour of classes you've written, not the built-in one in matlab.
The simplest solution would be for you to upgrade to 2014b (or better 2015a, considering that 2015b is due soon). If that's not feasible, your colleague will have to change the way he saves graphics to the .mat file. Instead of saving a figure handle, he would have to save its number (that is, if before he was saving hfig, he would now have to save hfig.number as hfig). For a uicontrol, I'm not too sure how you would go about it, possibly save the uicontrol.tag instead while you would use findobj with with the tag to find back the control after you've loaded the file.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!