我目前正在使用GUIDE创建一个GUI(我比较新)。我希望能够让最终用户选择一个.csv文件加载到GUI中,并将其显示在表格中。到目前为止,我使用以下代码:
function loadBtn_Callback(hObject, eventdata, handles)
% hObject handle to loadBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname]=uigetfile({'*.csv'}, 'Select File');
if isequal(filename,0)
return
else
Path=strcat(pathname,filename);
data=readtable(Path, 'Delimiter', ';');
set(handles.data_table, 'Data', data);
end
guidata(hObject, handles);
但是,我一直收到以下错误:
Error using matlab.ui.control.Table/set
While setting the 'Data' property of 'Table':
Data must be a numeric, logical, or cell array
我尝试在普通脚本中运行相同的代码并且工作正常,我做错了什么?