Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

GUI Data Acquisition Backwards

조회 수: 2 (최근 30일)
Zeke Merchant
Zeke Merchant 2014년 11월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Sean de Wolski
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
Sean de Wolski 2014년 11월 26일
Okay, it returns it - but what does it do with it? Does it store it to handles?
Zeke Merchant
Zeke Merchant 2014년 11월 26일
편집: Zeke Merchant 2014년 11월 26일
Yes it stores properly. I checked the dimensions by printing the handles list. It's just storing the data for the wrong column.
It is supposed to be stored into the handle called handles.datapatch
Data patch is used later in a function that creates a matrix where the first row is the data patch (either head data or plate data, depending on what is chosen) array of te first file in the data folder. The second row is the second file, etc.
That matrix is to be used later to plot many trials on the same plot. The ultimate goal is to look for a correlation between data files.

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by