Import Several txt files [Error: Getting only first line of first file]

조회 수: 1 (최근 30일)
Angel Lira
Angel Lira 2020년 4월 15일
댓글: Angel Lira 2020년 4월 15일
Hi, I am trying to open several txt files into Matlab, as multiples 2d arrays.
These files have float contents and integers all mixed. The files also, might not have the same sizes.
I have searched some online answers and I was using several ideas, however, I got as further as to read the first line of the first file. But that is not the result I wanted.
As example of the files I am using I have the attachements.
The following is the code I am using.
Folder = pwd;
Files = dir(fullfile(Folder, '*.txt'));
Result = cell(1, numel(Files));
for j = 1:numel(Files)
aFile = fullfile(Folder, Files(j).name);
Data = csvread(aFile);
end

답변 (1개)

Mehmed Saad
Mehmed Saad 2020년 4월 15일
Replace csvread with readmatrix
Data = readmatrix(aFile);
  댓글 수: 1
Angel Lira
Angel Lira 2020년 4월 15일
I changed it and it just shows me the content of the first file. Not the content of all files. Do you know how can i solve it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by