필터 지우기
필터 지우기

How to combine multiple .dat files.

조회 수: 32 (최근 30일)
Ahmed Alsaadi
Ahmed Alsaadi 2018년 11월 21일
댓글: Image Analyst 2022년 4월 11일
I have 5 files (.dat) that are 2x20 (row,col) I want to import them and combine them in one file, the new file should (10x20)

채택된 답변

Image Analyst
Image Analyst 2018년 11월 21일
Just call csvread or dlmread 5 times, then concatenate, then call csvwrite
m1 = csvread(filename1);
m2 = csvread(filename2);
m3 = csvread(filename3);
m4 = csvread(filename4);
m5 = csvread(filename5);
mOut = [m1;m2;m3;m4;m5];
csvwrite(fileNameOut, mOut);
  댓글 수: 3
Katey Faber
Katey Faber 2022년 4월 11일
편집: Katey Faber 2022년 4월 11일
Is there an easy way for use a for loop with this method to csvwrite() hundreds of files?
Image Analyst
Image Analyst 2022년 4월 11일
You can use a for loop
outputFolder = 'c:\whatever';
if ~isfolder(outputFolder)
mkdir(outputFolder);
end
for k = 1 : 200
data = GetNewDataSomehow();
baseFileName = sprintf('File #%2.2d.csv', k)
fullFileName = fullfile(outputFolder, baseFileName);
writematrix(data, fullFileName);
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by