Why axes handles disappeared after call of slider callback function?

1 Ansicht (letzte 30 Tage)
Sergey Lopatnikov
Sergey Lopatnikov am 24 Mär. 2017
Beantwortet: Jan am 24 Mär. 2017
I used simple callback function for slider and when tried to set value to axes handles.axpulse, I got that there is no such a field. I checked this and found that before I call slider callback (in my case - fftmin(hObject,event_data,handles)) I have complete list of handles:
handles_1 =
figure1: [1x1 Figure]
text3: [1x1 UIControl]
HIT: [1x1 UIControl]
download: [1x1 UIControl]
output: [1x1 Figure]
Signal: [62504x3 double]
ftt: [1x1 Figure]
fftmin: [1x1 UIControl]
fftmax: [1x1 UIControl]
axpulse: [1x1 Axes]
axsig: [1x1 Axes]
However, after the call, the list changed and handles to axes fields disappeared:
figure1: [1x1 Figure]
text3: [1x1 UIControl]
HIT: [1x1 UIControl]
download: [1x1 UIControl]
output: [1x1 Figure]
Signal: [62504x3 double]
ftt: [1x1 Figure]
fftmin: [1x1 UIControl]
Why? And how to fight this?
  1 Kommentar
Adam
Adam am 24 Mär. 2017
Please show all relevant code otherwise we are just guessing what you might have done without seeing the callback in question.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 24 Mär. 2017
I guess your slider callback does something like this:
function sliderCallback(hObject, EventData, handles)
...
handles.xyz = get(hObject, 'Value');
guidata(hObject, handles);
end
The the handles struct from the inputs is used, but this is not the current value, but is the the state of the handles struct during the creation of the callback. To get the current value, obtain it from the figure:
function sliderCallback(hObject, EventData, handles_FromInputs)
handles = guidata(hObject); % <-- Get current value
...
The handles struct causes problems such frequently, that I consider it as design error.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by