How to read spreadsheet files iteratively?
4 次查看(过去 30 天)
显示 更早的评论
I am trying to access .xls files that are indexed in the following approach:
for a=1:5
filename = sprintf('%s_%d','Set_90',a);
fname=readtable('filename.xls');
But obviously, 'readtable' function is calling a file named 'filename.xls' and not 'Set_90_1.xls' . How do I change the code, in order to call the latter?
Thanks.
0 个评论
采纳的回答
per isakson
2020-5-9
Replace
readtable('filename.xls');
by
readtable( [ filename, '.xls' ] );
to use the value of the variable not its name.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!