Filter löschen
Filter löschen

From 2D data to a 3D matrix

2 Ansichten (letzte 30 Tage)
matnewbie
matnewbie am 24 Mai 2018
Erneut geöffnet: Stephen23 am 25 Mai 2018
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 Kommentar
Stephen23
Stephen23 am 24 Mai 2018
Bearbeitet: Stephen23 am 24 Mai 2018
@matnewbie: what file format do the files use? What size are the 2D matrices?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Nicola Bombace
Nicola Bombace am 24 Mai 2018
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 am 24 Mai 2018
for i = 1:128
x = sprintf('7528_00%03d.txt',i);
%load your file using x
end

Stephen23
Stephen23 am 24 Mai 2018
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

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by