%% Read Subset of EDF File
% Create an edfinfo object to obtain information about the EDF file example.edf. Extract the number of records and the names of the variables contained in the file.

info = edfinfo('example.edf');

nrec = info.NumDataRecords
vars = info.SignalLabels

%
% Read the second and fifth records corresponding to the variable ECG2. Return the signals as timetables with row times corresponding to signal sample times. Express the time information as datetime arrays.

data = edfread('example.edf', ...
    'SelectedDataRecords',[2 5],'SelectedSignals',"ECG2", ...
    'DataRecordOutputType','timetable','TimeOutputType','datetime')

%
% Change the name of the row times to "Date and Time" and the name of the variable to "Electrocardiogram".

data.Properties.DimensionNames = ["Date and Time" "Variables"];
data.Properties.VariableNames = "Electrocardiogram";

data

% Copyright 2020 The MathWorks, Inc.