How to read multiple files in a loop in sequential order and plot them as matrix

 采纳的回答

txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
iwant = cell(1,N) ;
for i = 1:N
iwant{i} = importdata(txtFiles(i).name) ;
end
% works if all cells are of same size
M = cell2mat(iwant) ;
pcolor(M) ;
shading interp

2 个评论

Thanks for your help. I tried this code. My original file has 1444 subfiles and still I am not able to read it in sequential order. My file name is 1_1_1.txt, 1_1_2.txt .........38_1_38.txt . The code is reading the files only from the series 10_1_1.txt
It has to read all the files. What is the value of N and number of files in the folder..are not they same?
You can have a look on the following fileexchange.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by