Why axes handles disappeared after call of slider callback function?

조회 수: 1 (최근 30일)
Sergey Lopatnikov
Sergey Lopatnikov 2017년 3월 24일
답변: Jan 2017년 3월 24일
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
Adam
Adam 2017년 3월 24일
Please show all relevant code otherwise we are just guessing what you might have done without seeing the callback in question.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 3월 24일
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.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by