Correct use of get(H,'Property Name')

2 vues (au cours des 30 derniers jours)
Jonas Reichert
Jonas Reichert le 29 Jan 2017
Commenté : Stephen23 le 29 Jan 2017
When I use get(H,'Property Name') and insert H manually, it works fine, but as soon as I try to define a variable H and insert it afterwards, get does not work any longer, no matter which data type i choose for H. How can I solve this problem?
  1 commentaire
Stephen23
Stephen23 le 29 Jan 2017
"..I try to define a variable H and insert it afterwards.."
What would be the desired effect? For example:
H = 1.2;
get(H,'Children')
What should this do???

Connectez-vous pour commenter.

Réponses (2)

Star Strider
Star Strider le 29 Jan 2017
In this context, ‘H’ is a handle, and the output of the creation of a specific object (for example figure, text, line etc.). You cannot just assign ‘H’ as an arbitrary variable and then use it with the get or set functions, because it has no meaning. Unless ‘H’ refers to an object with properties, using it with set or get is meaningless.

Image Analyst
Image Analyst le 29 Jan 2017
Not sure what you're doing to define H but if you did it properly it should work. For example
H = handles.slider1; % Get the handle to your slider control.
% Now get the slider value:
sliderValue = get(H, 'Value'); % or sliderValue = H.Value in new MATLAB versions.

Catégories

En savoir plus sur Debugging and Analysis dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by