How can I visualized the multiple tables read from a for loop in the variable space?

조회 수: 4 (최근 30일)
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

채택된 답변

Simon Chan
Simon Chan 2021년 7월 23일
Use cell array instead:
variables{i} = table(dataArray);
  댓글 수: 1
DulceEien
DulceEien 2021년 7월 23일
thank you, it is working I can not see like the whole table, but if I click each array then I see the values of each column

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chunru
Chunru 2021년 7월 23일
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}

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by