App Designer: Error using readtable "filename" must be a string scalar or character vector.
9 次查看(过去 30 天)
显示 更早的评论
Hello,
Please help me to resolve this issue I've been struggling with for hours on end.
My goal is to use multiselect to select several files and import them as tables to be manipulated independently via the GUI
app.ListBoxFileNames.Items = fileList
app.ListBoxPlotNames.Items
[file, path] = uigetfile('*.*','MultiSelect','on')
if noFiles == 1 % Code works for 1 file
initTable = readtable(file); % init table I think work with in the GUI
app.ListBoxFileNames.Items = fileList; % this is a cell
app.ListBoxPlotNames.Items = fileList;
else % Issues when using multiselect
for i=1:numel(file)
fileListNew = fileList(:,i)
% Below I try to use a structArray to contain a structure consisting of all the tables I import, as I don't know how else to work with the multiple tables
structArray(i) = table2struct(readtable((fileListNew))) % structArray(i)'s I would also like to work with independently in the GUI as separate tables.
app.ListBoxFileNames.Items{i} = fileList;
app.ListBoxPlotNames.Items{i} = fileList;
end
end
Any meaningful assistance would be appreciated. Thank you.
采纳的回答
Cris LaPierre
2021-1-14
编辑:Cris LaPierre
2021-1-14
I suspect the error is with how you are indexing you file names.
First, what is fileList? Shouldn't you be using the files that were just selected? That's file, which is a cell arry. Try using curly braces to index your cell instead of parentheses.
structArray(i) = table2struct(readtable(file{i}));
5 个评论
Cris LaPierre
2021-1-14
You might consider a table of tables (see here). However, if you now have a clearer idea of how to organize your data, take the opportunity to do that.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!