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

3 visualizzazioni (ultimi 30 giorni)
Jonas Reichert
Jonas Reichert il 29 Gen 2017
Commentato: Stephen23 il 29 Gen 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 Commento
Stephen23
Stephen23 il 29 Gen 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???

Accedi per commentare.

Risposte (2)

Star Strider
Star Strider il 29 Gen 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 il 29 Gen 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.

Categorie

Scopri di più su Debugging and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by