Reference to non-existent field error in a GUI

1 view (last 30 days)
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.

Accepted Answer

Image Analyst
Image Analyst on 15 Jan 2014
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().
  1 Comment
Doris
Doris on 16 Jan 2014
I am calling it upon clicking a button, yes. Thanks, I think I need to re-install matlab. In case that doesn't work, I will send the .m and .fig files. But I suspect it will...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!