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

2 visualizaciones (últimos 30 días)
Jonas Reichert
Jonas Reichert el 29 de En. de 2017
Comentada: Stephen23 el 29 de En. de 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 comentario
Stephen23
Stephen23 el 29 de En. de 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???

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 29 de En. de 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 el 29 de En. de 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.

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by