how to read multiple mat files and and extract data from those
23 次查看(过去 30 天)
显示 更早的评论
I have a multiple .mat files (like 100 file) I need to load and extract specific data from those files. I.e to extract the row and columns so can anyone please help me out in this.
2 个评论
Kevin Chng
2018-10-7
mat = dir('*.mat');
for q = 1:length(mat)
load(mat(q).name);
end
Hi, i see there is answer in https://www.mathworks.com/matlabcentral/answers/139879-how-to-read-all-mat-files-from-a-folder-in-matlab
However, you are mentioning you want to extract specific data from those files. As per my knowledge, may be we need to know what is the name of variable in the mat file first.
May be you can attach few of your mat file, and further elaborate it. So may be some of expert here can try it out.
采纳的回答
Kevin Chng
2018-10-7
Hi Suhas Goravale Siddaramu,
I have tried out your attached mat. file. I guess you are saying row 11 instead of column 11. In your mat.file, there is variable Pre-cell, it has 3 columns and 14 rows.
mat = dir('*.mat');
for q = 1:length(mat)
load(mat(q).name);
data(q,:) = Pre_cell(11,:)
end
with the additional line of code data(q,:) = Pre_cell(11,:), it will load all the row 11 of mat file into data.
Should you have any doubt, you may ask.
4 个评论
更多回答(1 个)
ANKUR KUMAR
2018-10-7
Whenever you wish to load all files, just use dir.
F=dir('*.mat')
for i =1:length(F)
load(F(i).name)
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!