the meaning of basic matlab words
Afficher commentaires plus anciens
can any one explain to me the meaning of the "handle" word in details.
because I see this word in many matlab documentation, and then the things get complicated.
3 commentaires
Adam
le 13 Fév 2020
Beware of the fundamental difference between 'handle' and 'handles', which you will likely see both of. Image Analyst has given a description of what a 'handle' is. It's the same kind of concept as a jug or cup handle, in the sense of allowing you to use the object easily. If you ever do object-oriented programming in Matlab then a 'handle' class has some key properties that are different from a default (by value) class.
Chief amongst these is that they are passed around by reference, which is not standard behaviour for Matlab objects. Graphics objects, where you will most often interact with the concept of handles, have this property.
'handles', on the other hand, is something you will hear more in relation to GUIs created using GUIDE - a tool that is no longer recommended for use, but still works perfectly well and, for many of us, better than app designer currently.
In GUIDE, 'handles' simply refers to a struct which contains the handles of all the GUI components. It is important to note that this behaves like any other struct - i.e. it does not have 'pass-by-reference' semantics itself, even though the GUI handles it contains do.
Osama Alkurdi
le 13 Fév 2020
Modifié(e) : Osama Alkurdi
le 13 Fév 2020
"did you mean that 'handle' is like cup that stores properties of an certain kind object and I can't interact with these properties"
Not at all.
As Adam wrote, a handle is like a cup handle, it is not like the cup itself. A handle is a way to reference an object, but it is not the object itself. You can certainly interact with the properties of an object you have a handle of.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 13 Fév 2020
Usually it's basically a variable that contains everything you need to interact with something, such as a graphical object displayed on your screen. For example gcf is the handle to the current figure (the whole window), and gca is the handle to whatever axes object on that figure was drawn to last. You can use those to set all kinds of properties, like to maximize the figure:
% Create a new figure and store its handle in a variable (an object) called hFig.
hFig = figure
% Maximize that figure.
hFig.WindowState = 'maximized'
1 commentaire
Osama Alkurdi
le 13 Fév 2020
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!