Unrecognized property Value for class Axes?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I have been trying to create a CT scan viewer through Matlab.
It is up and running, however, I am getting the error Unrecognized property Value for class Axes whenever I change and image.
It hightlights these two lines of code for me.
% Add listener to the slider to call a function when its value changes
addlistener(hSlider, 'Value', 'PostSet', @(src, event) updateImage(src, event, hAxes, dicomImages));
and
% Get the current value of the slider
sliderValue = round(get(hAxes.Parent.Children(2), 'Value')); % hAxes.Parent.Children(2) is the slider handle
Would anyone know where I went wrong?
0 comentarios
Respuestas (2)
Steven Lord
el 2 de Ag. de 2024 a las 13:32
Why do you believe that hAxes.Parent.Children(2) is the handle to your slider? I would not assume that the handles of the children of the axes's parent are always in order such that the second child is the slider.
0 comentarios
dpb
el 2 de Ag. de 2024 a las 13:53
Movida: dpb
el 2 de Ag. de 2024 a las 13:53
% Get the current value of the slider
sliderValue = round(get(hAxes.Parent.Children(2), 'Value')); % hAxes.Parent.Children(2) is the slider handle
Use the app-assigned handle to the slider (with your customized name if desired), not some attempt to find it by ad hoc code. Clearly by the error message, what you've actually returned is an axes object, NOT the slider, so it isn't what you think it is.
The standard callback function for the ValueChanged callback looks like:
% Value changed function: Slider
function SliderValueChanged(app, event)
value = app.Slider.Value;
... do whatever here ...
end
NOTA BENE the app.Slider handle that App Designer provides that is in the app struct created automgically for you. It will have your specific name for the slider in question there--use it.
That is a general precept for ALL controls; if you have similar other code for other controls, you need to fix them as well.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!