hObject, eventdata and handles not return double in R2016a
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 26 Apr. 2016
Bearbeitet: Walter Roberson
am 26 Apr. 2016
0 Stimmen
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
am 26 Apr. 2016
0 Stimmen
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.
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!