Error Opening File with readtable

3 visualizzazioni (ultimi 30 giorni)
Maciej Olszewski
Maciej Olszewski il 11 Lug 2019
Risposto: Walter Roberson il 11 Lug 2019
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!

Risposte (1)

Walter Roberson
Walter Roberson il 11 Lug 2019
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')

Categorie

Scopri di più su Variables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by