MATLAB: How to combine the multiple .mat files of ecg to get a single file.

atrialfibrillationecg

I have 23 files(in .mat) of atrial fibrillation database. i want to combine all these mat files to get a matrix of (23*2500) where 2500 is the samples of each .mat files and 23 is the no of records or no. of files.
Please help!

Best Answer

This should get you started:
D = 'path to the folder where the files are saved';
S = dir(fullfile(D,'*.mat'));
for k = 1:numel(S)
F = fullfile(D,S(k).name);
T = load(F);
S(k).data = T.val;
end
M = vertcat(S.data);
save(fullfile(D,'merged.mat'),'M')