Info
此问题已关闭。 请重新打开它进行编辑或回答。
GUI Data Acquisition Backwards
1 次查看(过去 30 天)
显示 更早的评论
Need:
I have several excel files all put in a folder entitled "data"
This GUI is supposed to grab those files but the acquisition is currently backwards.
The two data sets I am interested in are labeled "HeadRight" and "RightFrontPlate" in the column labels of the excel files.
Code:
% --- Executes on button press in choosedir.
function choosedir_Callback(hObject, eventdata, handles)
% hObject handle to choosedir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
directory = uigetdir;
set(handles.textbox1,'String',directory);
guidata(hObject,handles)
% --- Executes on button press in readdir.
function readdir_Callback(hObject, eventdata, handles)
% hObject handle to readdir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
directory=get(handles.textbox1,'String');
files=dir(directory);
for i=1:(length(files)-2)
s=files(i+2).name;
s=strcat('\',s);
L=strcat(directory, s);
[num, txt, all] = xlsread(L); %%your excel file must not have first line titles
for j=1:length(txt);
txt{j}=regexprep(txt{j},'','NaN');
%delete space in string
% text{j}=num(:,j);
handles.data(i).(txt{j})=num(:,j);
guidata(hObject,handles);
end
guidata(hObject,handles)
end
display('Data reading is complete.')
% --- Executes on button press in headdata.
function headdata_Callback(hObject, eventdata, handles)
% hObject handle to headdata (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of headdata
handles = guidata(hObject);
if (get(hObject,'Value') == get(hObject,'Max'))
for i = 2:length(handles.data);
handles.datapatch = handles.data(i).HeadRight;
handles.int = handles.data(1).DetectionCode;
end
guidata(hObject,handles)
display('headdata works');
end
% --- Executes on button press in platedata.
function platedata_Callback(hObject, eventdata, handles)
% hObject handle to platedata (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of platedata
handles = guidata(hObject);
if (get(hObject,'Value') == get(hObject,'Max'))
for i = 2:length(handles.data);
handles.datapatch = handles.data(i).RightFrontPlate;
handles.int = handles.data(1).DetectionCode;
end
guidata(hObject,handles)
display(handles.data(2).RightFrontPlate(1))
display('platedata works');
end
Issue:
For some reason, the GUI subfunction used to call the HeadRight data returns an error message saying that the variable "HeadRight" is undefined. Running the GUI subfunction used to call the RightFrontPlate data returns the HeadRight data
0 个评论
回答(1 个)
Sean de Wolski
2014-11-26
Put a break point on that line throwing the error and stop to see what's happening, what is HeadRight? Where did it come from? Did the place that it is supposed to come from ever run? Put a breakpoint there and repeat!
3 个评论
Sean de Wolski
2014-11-26
Okay, it returns it - but what does it do with it? Does it store it to handles?
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!