Error Opening File with readtable

I am trying to open couple of files in different directories all that have the same name, because it is a long list (I only attached a short list here) I put it in a for loop. I know that the file does exist and that the path is correct from where I run.
for name = {'747','585','9555'}
filename = '/sort_pos.txt';
filename = strcat(name,filename);
A = table2array(readtable(filename,'Format','%f\t%f\t%f'));
end
The error I get is:
"Error using readtable (line 143)
Input must be a row vector of characters."
Any help would be amazing, thanks!

回答(1 个)

Inside your loop name is a cell array of character vector and strcat involving it is going to return a cell array of character vector which readtable cannot process.
fullfile(name{1}, 'sort_pos.txt')

类别

帮助中心File Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by