Unrecognized property Value for class Axes?
11 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Steven Lord
on 2 Aug 2024
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 Comments
dpb
on 2 Aug 2024
Moved: dpb
on 2 Aug 2024
% 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 Comments
See Also
Categories
Find more on Graphics Object Programming 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!