function [averageDiff,features]=findECGpeaksNewFeaturesPlayQRSWen(yp,QRS)
% [averageDiff,~,~]=findPCGpeaksNewFeatures2(yp);
% Diffv=abs(diff(Indexes(:,1)));
averageDiff=median(diff(QRS));
feats1=[];feats2=[];feats3=[];feats4=[];feats5=[];feats6=[];feats7=[];feats8=[];feats9=[];
for i=1:length(QRS)-1    
    ypp=yp(QRS(i)+1:QRS(i+1));
    ypps=sort(ypp);
    went1=wentropy(ypps(1:round(end/5)),'shannon');
    went2=wentropy(ypps(round(end/5):round(2*end/5)),'shannon');
    went3=wentropy(ypps(round(2*end/5):round(3*end/5)),'shannon');
    went4=wentropy(ypps(round(3*end/5):round(4*end/5)),'shannon');
    went5=wentropy(ypps(round(4*end/5):round(end)),'shannon');
    %     wents=sort([went1,went2,went3,went4]);
    wents=min([went1,went2,went3,went4,went5]);
    wents2=median([went1,went2,went3,went4,went5]);
    wents3=max([went1,went2,went3,went4,went5]);
    
    feats1=[feats1,mean(ypp)];
    feats2=[feats2,std(ypp)];
    [peakLoc1, peakMag1] = peakfinder(ypp);
    val3=std(peakMag1);
    llp=length(peakLoc1);
    val4=std(peakLoc1);
    if isnan(val3)==1
        val3=0;llp=0;val4=0;
    end
    feats3=[feats3,llp];
    feats4=[feats4,moment(ypp,4)];
    feats5=[feats5,kurtosis(ypp)];
    feats6=[feats6,moment(ypp,6)];
    feats7=[feats7,wents];
    feats8=[feats8,val3];
    feats9=[feats9,val4];
%     feats10=[feats10,wents];
%     feats11=[feats11,wents];
%     feats12=[feats12,wents];
    
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)))];
len3=length(feats3);
features3=[median(feats3(1:round(len3/3))),median(feats3(round(len3/3):round(2*len3/3))),median(feats3(round(len3/3):end))];
features3=[features3,abs(features3-median(feats3))];
features3a=[median(abs(feats3(1:round(len3/3)))),median(abs(feats3(round(len3/3):round(2*len3/3)))),median(abs(feats3(round(len3/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)))];
features7=[median(feats7(1:round(len/3))),median(feats7(round(len/3):round(2*len/3))),median(feats7(round(len/3):end))];
features7=[features7,abs(features7-median(feats7))];
features7a=[median(abs(feats7(1:round(len/3)))),median(abs(feats7(round(len/3):round(2*len/3)))),median(abs(feats7(round(len/3):end)))];
features7a=[features7a,abs(features7a-median(abs(feats7)))];

features8=[median(feats8(1:round(len/3))),median(feats8(round(len/3):round(2*len/3))),median(feats8(round(len/3):end))];
features8=[features8,abs(features8-median(feats8))];
features8a=[median(abs(feats8(1:round(len/3)))),median(abs(feats8(round(len/3):round(2*len/3)))),median(abs(feats8(round(len/3):end)))];
features8a=[features8a,abs(features8a-median(abs(feats8)))];

features9=[median(feats9(1:round(len/3))),median(feats9(round(len/3):round(2*len/3))),median(feats9(round(len/3):end))];
features9=[features9,abs(features9-median(feats9))];
features9a=[median(abs(feats9(1:round(len/3)))),median(abs(feats9(round(len/3):round(2*len/3)))),median(abs(feats9(round(len/3):end)))];
features9a=[features9a,abs(features9a-median(abs(feats9)))];

% features=[features1,features2,features3,features4,features5,features6,features7,features8,features9,features1a,features2a,features3a,features4a,features5a,features6a,features7a,features8,features9];
features=[features1,features2,features3,features4,features5,features6,features7,features1a,features2a,features3a,features4a,features5a,features6a,features7a];
