Reference to non-existent field error in a GUI
조회 수: 1 (최근 30일)
이전 댓글 표시
hello,
I was working with a GUI analyzing some videos for the past months and everything went ok. I re-installed MATLAB (R2013a, from a R2011 I think) and now I have some problem using the GUI:
I open the gui and want to load some frames. When I'm asked to type in the first file to load (lb) I get the error:
Reference to non-existent field 'lb_frame'.
Error in plotVisualizer>LoadData_Callback (line 4182) set(handles.lb_frame,'String',lb);
The code is:
function LoadData_Callback(hObject, ~, handles)
str = {'Dance Data'};
[data_type,ok] = listdlg('PromptString','Select Data Type:', 'SelectionMode',...
'single','ListString',str,'ListSize',[160 160]);
handles.data_type = data_type;
h = msgbox('Please indicate the range of configured data you would like to load');
uiwait(h);
lb = str2num(cell2mat(inputdlg('Please type the number of the first file to load')));
set(handles.lb_frame,'String',lb);
ub = str2num(cell2mat(inputdlg('Please type the number of the last file to load')));
set(handles.ub_frame,'String',ub);
if data_type == 1
old_dir = cd;
location = uigetdir('','Please browse to Dance folder');
addpath(location);
cd(location);
for n = lb:ub
file =[num2str(n) '.dat']
handles.dancedata{n} = importdata(file);
end
cd(old_dir);
end
handles.lb = lb;
handles.ub = ub;
guidata(hObject,handles);
--- so basically I type in the frames I want and I want to load the corresponding files. This used to work ok, but now if I type 'handles' before
lb = str2num(cell2mat(inputdlg('Please type the number of the first file to load')));
set(handles.lb_frame,'String',lb);
... I see that indeed lb_frame is not attached to the handles!
handles =
data_type: 1
My callback function for lb_frame is there and the tag for lb_frame is ok.
댓글 수: 0
채택된 답변
Image Analyst
2014년 1월 15일
Everything sounds ok. No "clear" in there to erase handles, and you say there is a control called lb_frame, and yet when you type out handles immediately upon entering the function it's empty and only gets the data_type field after you assign that. So something's weird and I think you'll have to attach the fig file, and maybe the m-file for us to check out why handles is empty upon calling LoadData_Callback().
How are you calling it? You're not calling it directly from another function are you? You're calling it only upon clicking the button right? If you called it from a function and that function had a clear all in there, then it erased handles and will be empty upon entering LoadData_Callback().
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!