What is the difference between ishghandle and isgraphics?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is something that I have wondered for a while. I like to do a lot of validating of things in my code, one of which is to check if some graphics object (e.g. a figure) is still valid or whether I need to recreate it.
I always tended to use ishghandle ( note: not ishandle which I know is different) because I didn't know about isgraphics.
But is there some subtle difference I am not understanding? The descriptions differ only by isgraphics saying it returns true for valid graphics handles. But ishghandle returns false on a deleted axes, closed figure etc too so I am not aware of a case in which these too differ in result.
ishghandle documentation does talk about Simulink objects, though in relation to a comparison with ishandle, but I don't have Simulink so I can't test if this is a place where ishghandle and isgraphics differ.
I guess it doesn't matter and I can use either one if they both return true or false when I want them too, I'm just curious.
1 commentaire
dpb
le 7 Déc 2016
Modifié(e) : dpb
le 7 Déc 2016
I don't have HG2 so don't have either but from the doc it looks to me like ishghandle is an early incarnation of isgraphics -- it lacks the second optional type argument and the doc doesn't provide the "Introduced" revision level. It would not surprise me to find it deprecated one of these days.
The rate of change recently has really introduced "a veritable plethora" of warts with objects and data types coming into and going out of favor so rapidly it's impossible to keep up and make any heads nor tails of where TMW is really going--not sure they know in long term themselves, they're introducing features so fast there's not time to ever assimilate them all into a cogent whole on a release-by-release basis.
Réponse acceptée
David Barry
le 7 Déc 2016
isgraphics was introduced in R2014b along with HG2. You can replace all instances of ishghandle with isgraphics going forward and your old code will still work. The new optional 2nd input to isgraphics allows you to also check for type.
The old way still works:
H = plot(rand(5));
isgraphics(H)
But you can now also optionally check for type:
H = plot(rand(5));
a = [H;gca;gcf];
isgraphics(a,'line')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Programming dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!