hObject, eventdata and handles not return double in R2016a
Show older comments
Hi I am running a GUI program under R2016a and found the hObject, eventdata and handles are not return doubles as in R2014a before, which give me error 'Expected input to be one of these types: numeric, instead its type was matlab.ui.Figure' and 'error while evaluating UICotrol Callback'. Is there any way to let these functions return doubles as before, or alternate way to make the whole GUI work? Thanks very much.
Accepted Answer
More Answers (2)
Walter Roberson
on 26 Apr 2016
Edited: Walter Roberson
on 26 Apr 2016
0 votes
What is it that is expecting its input to be numeric instead of figure?
There is no way to configure the functions to return numeric handles now.
The best alternative method is to change your code to not expect doubles.
If somehow that cannot be done, then take double() of the handle and use that as the numeric value. In another couple of releases this method will no longer be supported.
Mike Garrity
on 26 Apr 2016
0 votes
There was quite a bit of documentation on this as part of the R2014b release. This page from the transition guide will probably be helpful. In addition, there was a series of posts (starting with this one) on Loren's blog that might be helpful. There's also this tool on the File Exchange which can identify common issues.
The short version is that it is possible to coerce the handles into doubles, but it's really much better to identify why your code is assuming that they are doubles and fix that. Where is that error message coming from? It sounds like it's from validateattributes. If the call to validateattributes is in your code, you might be able to add matlab.ui.Figure to the list of accepted classes.
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!