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

2 views (last 30 days)
Jonas Reichert
Jonas Reichert on 29 Jan 2017
Commented: Stephen23 on 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 Comment
Stephen23
Stephen23 on 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???

Sign in to comment.

Answers (2)

Star Strider
Star Strider on 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 on 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.

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!