필터 지우기
필터 지우기

concatenate data files horizontally into one file

조회 수: 2 (최근 30일)
Cody
Cody 2012년 1월 23일
Hello,
I have several data files with the same number of rows and I need to concatenate them all into one big file. For example, we might have the following two files:
data1.dat:
1 1
2 2
3 3
data2.dat
4 4 4
5 5 5
6 6 6
and I want to concatenate data files into one horizontally into one file like below.
Bigdata.dat
1 1 4 4 4
2 2 5 5 5
3 3 6 6 6
Thanks a lot

답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 23일
alldata = [];
for K = 1 : NumberOfFiles %looping over all of the files
thisfile = whatever %name of file #K
thisdata = load(thisfile);
alldata = [alldate, thisdata];
end
  댓글 수: 2
Cody
Cody 2012년 1월 23일
Thanks.
But my files' name is like this: xxx1xx.dat, xxx2xx.dat and xxx3xx.dat
So how can I do that?
Walter Roberson
Walter Roberson 2012년 1월 23일
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
alldata = [];
for K = 1 : NumberOfFiles %looping over all of the files
thisfile = sprintf('xxx%dxx.dat');
thisdata = load(thisfile);
alldata = [alldate, thisdata];
end

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by