Filter löschen
Filter löschen

Unrecognized property Value for class Axes?

23 Ansichten (letzte 30 Tage)
Karol Dunne
Karol Dunne am 2 Aug. 2024 um 13:05
Verschoben: dpb am 2 Aug. 2024 um 13:53
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?

Antworten (2)

Steven Lord
Steven Lord am 2 Aug. 2024 um 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.

dpb
dpb am 2 Aug. 2024 um 13:53
Verschoben: dpb am 2 Aug. 2024 um 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.

Community Treasure Hunt

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

Start Hunting!

Translated by