From 2D data to a 3D matrix

I have a folder with 2D data stored in 128 files (from number 001 to number 128), whose name has this general form:
7528_00###.txt
where ### represents numbers from 001 to 128. I want to load these data in a 3D matrix in MATLAB, because this is a more manageable data structure. What is the best approach to achieve this task?

댓글 수: 1

Stephen23
Stephen23 2018년 5월 24일
편집: Stephen23 2018년 5월 24일
@matnewbie: what file format do the files use? What size are the 2D matrices?

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

답변 (3개)

Nicola Bombace
Nicola Bombace 2018년 5월 24일

0 개 추천

Based on your comment, you could obtain the filename using a for loop and the function sprintf.
nFiles = 128;
for n = 1 : nFiles
filename = sprintf('%s%03d','7528_00',n);
% Process File
end
Aditya Adhikary
Aditya Adhikary 2018년 5월 24일

0 개 추천

for i = 1:128
x = sprintf('7528_00%03d.txt',i);
%load your file using x
end
Stephen23
Stephen23 2018년 5월 24일

0 개 추천

S = dir('7528_00*.txt');
N = numel(S);
A = nan(128,128,N);
for k = 1:N
S(k).name
A(:,:,k) = ... load your data file
end

카테고리

도움말 센터File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품

태그

질문:

2018년 5월 24일

다시 열림:

2018년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by