Loading multiple mat files using for loop
4 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to load multiple mat files in a particular folder. Right now i have 8 matfiles so i have written the code as below.
for k=1:8
S = load(sprintf('M%d.mat',k));
I donot to limit the number of files in code. Is there a way to find the matfiles in a folder and load all the mat files present in the folder.
1 个评论
KSSV
2020-11-12
This question discussed to death in mathworks........a simple google will give you tonns of links.
采纳的回答
Ameer Hamza
2020-11-12
编辑:Ameer Hamza
2020-11-12
You can use dir() command to iterate over all the .mat files. For example
files = dir('*.mat');
for i = 1:numel(files)
S = load(files(i).name)
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!