App Designer: Error using readtable "filename" must be a string scalar or character vector.
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Connor Fitzgerald
el 14 de En. de 2021
Comentada: Cris LaPierre
el 14 de En. de 2021
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.
1 comentario
Respuesta aceptada
Cris LaPierre
el 14 de En. de 2021
Editada: Cris LaPierre
el 14 de En. de 2021
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 comentarios
Cris LaPierre
el 14 de En. de 2021
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!