Change variable name in a loop
이전 댓글 표시
Hi,
I have multiple excel table data, that are imported to MATLAB in a loop function.
csvFiles = dir('*.csv');
numfiles_csv = length(csvFiles)
for a = 1:numfiles_csv
readtable(csvFiles(a).name)
end
I wish to name each table with numbers (e.g. table1, table2, etc.).
Currently when i run the code, all the tables are shown with a output name 'ans', which is preventing me from further allocation task.
thanks.
댓글 수: 3
"Currently when i run the code, all the tables are shown with a output name 'ans', which is preventing me from further allocation task"
The MATLAB documentation shows how to import files into a cell array (which is what you should do):
"I wish to name each table with numbers (e.g. table1, table2, etc.)."
That approach is not recommended, you should avoid doing that:
Sehoon Chang
2020년 8월 29일
Stephen23
2020년 8월 29일
"Could you please provide me with links or examples how i could make the tables visible,"
mydata_csv{1} % the 1st table
mydata_csv{2} % the 2nd table
mydata_csv{3} % the 3rd table
...etc
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!