Home > Enterprise >  how to read multiple text files in matlab
how to read multiple text files in matlab

Time:01-02

Could someone please help me, I have 40 txt files which I want to read into matlab so that each one will be displayed as a matrix (each file has 5 columns and 2025 rows). If I run this code, then txtfiles and j is displayed correctly, but T shows me just one matrix.... Thanks in advance!

txtfiles=dir('*.txt');
for j=1:length(txtfiles)
    T=readmatrix(txtfiles(j).name)
end

CodePudding user response:

you can instead write in the loop T as a cell or as an array, for example:

...
T{j}=...
...

or

T(:,:,j)=...
  • Related