Info

この質問は閉じられています。 編集または回答するには再度開いてください。

GUI Data Acquisition Backwards

1 回表示 (過去 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