필터 지우기
필터 지우기

Import and combine multiple XYZ.txt data files into one X, Y and Z column vectors

조회 수: 1 (최근 30일)
Hi
I have a large number of txt files with different names, each one has tab seperated values of X Y and Z data in 3 columns. I have been importing each file seperately but there must be a way to import all the files at once into just 3 column vectors? The files themselves are very large. Is it also possible to write the data into one txt file?
Any help on this would be much appreciated.
Thanks

채택된 답변

Arnaud Miege
Arnaud Miege 2011년 6월 6일
I don't think you can import all the files at once, but you can do so in a loop and append the data from each file to what has already been imported by concatenating the arrays. See the MATLAB FAQ for more details.
HTH,
Arnaud
  댓글 수: 4
scour_man
scour_man 2011년 6월 9일
thanks for helping but I still cant get it to work.. this is what I get now...
files=dir('*.txt')
for i=1:length(files)
fid = fopen(files(i));
C{i} = textscan(fid,'%f%f%f','Delimiter','tab','HeaderLines',1);
fclose(fid)
end
files =
15x1 struct array with fields:
name
date
bytes
isdir
datenum
??? Error using ==> textscan
First input can not be empty.
Arnaud Miege
Arnaud Miege 2011년 6월 9일
Check out what's 'files' in your workspace, it's probably a structure (for more details see the documentation for dir). You need to use files(i).name with fopen.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by