How can I create multiple variables for further processing in a for-loop from imported tables?
Mostra commenti meno recenti
Hi all,
I am working on improving the efficiency of codes created and have modified the codes from this example for my application: How can I process a sequence of files?
for k = 1:13
matFileName = sprintf('XXX_#%d.txt', k);
if exist(matFileName, 'file')
Table(k) = readtable(matFileName); % error here
% without error: Table = readtable(matFileName);
% save(['FileName' num2str(k)],'Table'); % Need to use a second loop to load the mat-files
else
fprintf('File %s does not exist.\n', matFileName);
end
end
How can I create workspace variables from these imported tables for further processing? This error was shown "Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript."
I have attempted to first save the imported tables and then load the mat.file using another for-loop. Is there a direct way of creating workspace variables from these imported tables in one single for-loop?
Thank you for your support.
1 Commento
Stephen23
il 25 Ago 2018
Better to read the MATLAB documentation:
Notice how they documentation imports the file data into a cell array. This is what you should do too, because using a cell array is simple and efficient.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!