Requesting to procedure to download Mutliple .mat file and to make as one .MAT and load the that .MAT file using Datastore using loop

1 次查看(过去 30 天)
Sir/Madam, I working in with LSTM , as was looking at the example , This example uses ECG data from the PhysioNet 2017 Challenge [1], [2], [3], which is available at https://physionet.org/challenge/2017/. The data consists of a set of ECG signals sampled at 300 Hz and divided by a group of experts into four different classes: Normal (N), AFib (A), Other Rhythm (O), and Noisy Recording (~). Load and Examine Data. if ~isfile('PhysionetData.mat')
ReadPhysionetData
end
load PhysionetData
The loading operation adds two variables to the workspace: Signals and Labels. Signals is a cell array that holds the ECG signals. Labels is a categorical array that holds the corresponding ground-truth labels of the signals.
I was not able to perform this , as I unable to load PhysionetData. I have downloaded the file , Unziped the file , kept all approx 8256 .MAT files in one folder called Physionet. Stuck after that , how to proceed further for loading . Please help in this.

回答(1 个)

Suraj Kumar
Suraj Kumar 2025-2-19
To combine multiple ".mat" files into a single ".mat" file and then load that data using a datastore in MATLAB, you can refer to the following steps:
1. You can load all the ".mat" files, loop through each file and combine the data into a single structure.Then you can save the data into a new ".mat" file.
fileList = dir(fullfile(folderPath, '*.mat'));
allSignals = {};
allLabels = {};
for i = 1:length(fileList)
filePath = fullfile(folderPath, fileList(i).name);
data = load(filePath);
allSignals{end+1} = data.Signal;
allLabels{end+1} = data.Label;
end
save('PhysionetData.mat', 'allSignals', 'allLabels');
2. After combining all the ".mat" files into a single file, you can load the combined data into MATLAB using the "load" function. The you can then create a table from the loaded signals and labels, which can be used with MATLAB's "datastore" for efficient data processing.
load('PhysionetData.mat', 'allSignals', 'allLabels');
dataTable = table(allSignals', allLabels', 'VariableNames', {'Signals', 'Labels'});
ds = datastore(dataTable);
while hasdata(ds)
dataChunk = read(ds);
end
To learn more about the "datastore" function in MATLAB, you can refer to the following link:

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by