Code:
d=load('CU_Ventricular_Tacharrhythmia\cu01m.mat');noisyECG_withTrend=d.val(1,:);subplot(2,1,1), plot(noisyECG_withTrend), grid on,nnoisyECG_withTrend = noisyECG_withTrend';t = 1:length(noisyECG_withTrend);[p,s,mu] = polyfit((1:numel(noisyECG_withTrend))',nnoisyECG_withTrend,6)f_y = polyval(p,(1:numel(noisyECG_withTrend))',[],mu);ECG_data = nnoisyECG_withTrend - f_y; % Detrend data
subplot(2,1,2), plot(t,ECG_data); grid on%ax = axis;
%axis([ax(1:2) -1.2 1.2])
title('Detrended ECG Signal')xlabel('Samples'); ylabel('Voltage(mV)')legend('Detrended ECG Signal')
Best Answer