How can I visualized the multiple tables read from a for loop in the variable space?
    4 views (last 30 days)
  
       Show older comments
    
When I run the script for one table, to visualize the table I just do like this (and it works fine):
% Create output variable
variables = table;

but when I'm reading multiple tables, how can I visualized the multiple tables read from a for loop in the variable space?
for i = 1:5
    filename = sprintf('variables_%d.csv',i)
    fileID(i) = fopen(filename,'r'); %check each file
    dataArray = textscan(fileID(i), '%C%f%f%f%f%f%C%s%f%f%f%f%f%f%[^\n\r]', 'Delimiter', ',', 'TextType', 'string', 'HeaderLines', 1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
    fclose(fileID(i));
    variables(i). = table();
end
I'm doing that but it is not working 
0 Comments
Accepted Answer
More Answers (1)
  Chunru
      
      
 on 23 Jul 2021
        Create a cell array of tables:
for i = 1:5
    filename = sprintf('variables_%d.csv',i)
    fileID(i) = fopen(filename,'r'); %check each file
    dataArray = textscan(fileID(i), '%C%f%f%f%f%f%C%s%f%f%f%f%f%f%[^\n\r]', 'Delimiter', ',', 'TextType', 'string', 'HeaderLines', 1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
    fclose(fileID(i));
    T{i} = table(dataArray);    % cell array of tables from the dataArray (modify this to create table)
end
% in workspace
T{2}
See Also
Categories
				Find more on Tables in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

