Why axes handles disappeared after call of slider callback function?
2 次查看(过去 30 天)
显示 更早的评论
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
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
2017-3-24
See https://www.mathworks.com/matlabcentral/answers/57550-faq-incomplete-handles-struct-in-callbacks:
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!