function [averageDiff,features]=findECGpeaksNewFeaturesPlayQRS(yp,QRS,QRS1,QRS2,QRS3,QRS4,QRS5)
% [averageDiff,~,~]=findPCGpeaksNewFeatures2(yp);
% Diffv=abs(diff(Indexes(:,1)));
lle=length(yp);
cqrts=length(QRS);
cqrts1=length(QRS1);
cqrts2=length(QRS2);
cqrts3=length(QRS3);
cqrts4=length(QRS4);
cqrts5=length(QRS5);

averageDiff=200;
if (cqrts)>2
    diff1=abs(diff(QRS));
    averageDiff=median(diff1);
end
averageDiff1=200;
if (cqrts1)>2
    diff1=abs(diff(QRS1));
    averageDiff1=median(diff1);
end

averageDiff2=200;
if (cqrts2)>2
    diff1=abs(diff(QRS2));
    averageDiff2=median(diff1);
end

averageDiff3=200;
if (cqrts3)>2
    diff1=abs(diff(QRS3));
    averageDiff3=median(diff1);
end

averageDiff4=200;
if (cqrts4)>2
    diff1=abs(diff(QRS4));
    averageDiff4=median(diff1);
end

averageDiff5=200;
if (cqrts5)>2
    diff1=abs(diff(QRS5));
    averageDiff5=median(diff1);
end

len=length(yp);
averageDiff=round(averageDiff);
averageDiff1=round(averageDiff1);
averageDiff2=round(averageDiff2);
averageDiff3=round(averageDiff3);
averageDiff4=round(averageDiff4);
averageDiff5=round(averageDiff5);

averageDiff=mean([averageDiff,averageDiff1,averageDiff2,averageDiff3,averageDiff4,averageDiff5]);
if isnan(averageDiff)
    averageDiff=200;
end
averageDiff=round(averageDiff);

feats1=[];feats2=[];feats3=[];feats4=[];feats5=[];feats6=[];
for i=1:averageDiff:len-averageDiff
    ypp=yp(i:i+averageDiff);
    feats1=[feats1,mean(ypp)];
    feats2=[feats2,std(ypp)];
    [peakLoc1, peakMag1] = peakfinder(ypp);
    val3=mean(peakMag1);
    llp=length(peakLoc1);
    if isnan(val3)==1
        val3=0;llp=0;
    end
    feats3=[feats3,llp];
    feats4=[feats4,moment(ypp,4)];
    feats5=[feats5,kurtosis(ypp)];
    feats6=[feats6,moment(ypp,6)];
end

len=length(feats1);
features1=[median(feats1(1:round(len/3))),median(feats1(round(len/3):round(2*len/3))),median(feats1(round(len/3):end))];
features1=[features1,abs(features1-median(feats1))];
features1a=[median(abs(feats1(1:round(len/3)))),median(abs(feats1(round(len/3):round(2*len/3)))),median(abs(feats1(round(len/3):end)))];
features1a=[features1a,abs(features1a-median(abs(feats1)))];
features2=[median(feats2(1:round(len/3))),median(feats2(round(len/3):round(2*len/3))),median(feats2(round(len/3):end))];
features2=[features2,abs(features2-median(feats2))];
features2a=[median(abs(feats2(1:round(len/3)))),median(abs(feats2(round(len/3):round(2*len/3)))),median(abs(feats2(round(len/3):end)))];
features2a=[features2a,abs(features2a-median(abs(feats2)))];

features3=[median(feats3(1:round(len/3))),median(feats3(round(len/3):round(2*len/3))),median(feats3(round(len/3):end))];
features3=[features3,abs(features3-median(feats3))];
features3a=[median(abs(feats3(1:round(len/3)))),median(abs(feats3(round(len/3):round(2*len/3)))),median(abs(feats3(round(len/3):end)))];
features3a=[features3a,abs(features3a-median(abs(feats3)))];

features4=[median(feats4(1:round(len/3))),median(feats4(round(len/3):round(2*len/3))),median(feats4(round(len/3):end))];
features4=[features4,abs(features4-median(feats4))];
features4a=[median(abs(feats4(1:round(len/3)))),median(abs(feats4(round(len/3):round(2*len/3)))),median(abs(feats4(round(len/3):end)))];
features4a=[features4a,abs(features4a-median(abs(feats4)))];

features5=[median(feats5(1:round(len/3))),median(feats5(round(len/3):round(2*len/3))),median(feats5(round(len/3):end))];
features5=[features5,abs(features5-median(feats5))];
features5a=[median(abs(feats5(1:round(len/3)))),median(abs(feats5(round(len/3):round(2*len/3)))),median(abs(feats5(round(len/3):end)))];
features5a=[features5a,abs(features5a-median(abs(feats5)))];
%
features6=[median(feats6(1:round(len/3))),median(feats6(round(len/3):round(2*len/3))),median(feats6(round(len/3):end))];
features6=[features6,abs(features6-median(feats6))];
features6a=[median(abs(feats6(1:round(len/3)))),median(abs(feats6(round(len/3):round(2*len/3)))),median(abs(feats6(round(len/3):end)))];
features6a=[features6a,abs(features6a-median(abs(feats6)))];
features=[features1,features2,features3,features4,features5,features6,features1a,features2a,features3a,features4a,features5a,features6a];
