The problem is immediately apparent on viewing the contents —
ViewContents = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/594720/reference_150ohmn.csv')
ViewContents =
{'Model' } {'MDO3024' }
{'Firmware Version' } {[ 1.1400]}
{'Waveform Type' } {'ANALOG' }
{'Point Format' } {'Y' }
{'Horizontal Units' } {'s' }
{'Horizontal Scale' } {[ 1]}
{'Horizontal Delay' } {[ 0]}
{'Sample Interval' } {[ 1.0000e-03]}
{'Record Length' } {[ 10000]}
{'Gating' } {'0.0% to 100.0%'}
{'Probe Attenuation'} {[ 1]}
{'Vertical Units' } {'V' }
{'Vertical Offset' } {[ 0]}
{'Vertical Scale' } {[ 0.0500]}
{'Vertical Position'} {[ 5]}
{'Label' } {1×1 missing }
Try this instead: —
reference_data=readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/594720/reference_150ohmn.csv', 'HeaderLines',16);
reference_data.Properties.VariableNames = {'TIME','REF1'};
reference_time=reference_data.TIME;
reference_voltage=reference_data.REF1;
Ts = mean(diff(reference_time))
filterred_reference=bandpass(reference_voltage,[0.51,59],Fs);
notch_frequencies=[58 61];
Sig_notch_reference=bandstop(filterred_reference,notch_frequencies,Fs);
f1=figure('units','normalized','outerposition',[0 0 1 1]);
plot(reference_time,reference_voltage,'k','LineWidth',1)
title('Reference Electrode, before filtering')
plot(reference_time,Sig_notch_reference,'k','LineWidth',1)
title('Reference Electrode, after filtering')
The filtering obviously needs work. Since I have no idea what you want to do, I will leave that to you.
I would apply the 60 Hz notch (bandstop) filter first, then use a bandpass filter with a bandwidth of 1 Hz to 100 Hz to filter the EKG. That willl remove the baseline wander and any remaining high-frequency noise without removing necessary parts of the EKG trace itself.
.