How can I import multiple text files in my folder to Matlab?

2 ビュー (過去 30 日間)
Zifeng Qiu
Zifeng Qiu 2020 年 10 月 26 日
回答済み: Cris LaPierre 2020 年 10 月 26 日
I am trying to import all the text files to matlab and make it an array, I used the following funciton to read in all the text files. But it is given me an error saying that the columns of the second line does not match with the first one, is there a way to skip the first line in the text file?
This is the code that I used:
files = dir('*.txt');
for i=1:length(files)
eval(['load ' files(i).name ' -ascii']);
end
And this is the error:
Error using load
Number of columns on line 2 of ASCII file 10.txt must be the same as previous lines.
Error in Project_1B (line 29)
eval(['load ' files(c).name ' -ascii']);

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 10 月 26 日
See my reply in this post.

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by