Why does ishghandle(0) alwys return true?
Mostra commenti meno recenti
Why does
ishghandle(0)
return true, even if there is no existent graphic object (actually, I executed this line of code first after Matlab startup).
Risposta accettata
Più risposte (1)
Georg Nestlinger
il 26 Gen 2021
4 Commenti
"I initilized a graphics object using gobjects(1) Then, checking with ishghandle() worked as expected in R2014b and above, but failed in R2013a."
What do you mean by "failed"? Did MATLAB crash, or did your computer stop responding, or did you just get an unexpected output? What output do you expect to get?
obj = gobjects(1);
ishghandle(obj)
Georg Nestlinger
il 26 Gen 2021
Stephen23
il 26 Gen 2021
AFAIK, versions before R2014b used numeric (double) scalars as a kind of graphics object "handle" (really more like an ID number). My guess is that the functions that "check" the existence simply have a different behavior when applied to doubles (IDs) vs graphics object handles.
In the back of my head I recalled an earlier discussion on this topic, but I can't find it now.
Is it really required to test for the existence of the graphics object? Surely if you are the author of your GUI and you keep track of the objects (by storing them in arrays, etc.), then there is little need to "guess" what graphics objects might be hanging around.
Georg Nestlinger
il 28 Gen 2021
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!