arrange columns side by side using matlab

Hii experts, i have 5000 .txt file in a directory that contains single column data. i want to arrange them side by side seqentially to make a mxn matrix file.
My files serial number starts from 1.txt 2.txt.....5000.txt

댓글 수: 2

Are the data numeric? Is the number of values the same in each file?
Seismic D
Seismic D 2021년 7월 3일
yes data is numeric like 2.867075e+01,6.455939e+00....etc

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

답변 (1개)

Scott MacKenzie
Scott MacKenzie 2021년 7월 3일
편집: Scott MacKenzie 2021년 7월 3일

0 개 추천

n = 5000; % number of files to read
basefilename = 'temp'; % change as necessary
M = []; % preallocate if you know the number of values in each file
for i=1:n
f = [basefilename num2str(i) '.txt'];
if isfile(f) % verify file exists (as a precaution)
M(:,i) = readmatrix(f);
end
end

댓글 수: 1

Seismic D
Seismic D 2021년 7월 3일
No it doesnot do what i expect....please modify script if possible

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

카테고리

도움말 센터File Exchange에서 Simscape Electrical에 대해 자세히 알아보기

태그

질문:

2021년 7월 3일

댓글:

2021년 7월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by