% function [data,HCDFVariables] = getHCDFInterval(Interval,dataset)

    feature = 'hcdf';
 Interval = 10;
 dataset = 1;

    clear Matrix
    
if dataset == 4
[Matrix,DJlangliste,Sektion] = getAllDJs(feature)

elseif dataset == 1
    
    [Matrix,DJlangliste,AntalUnikDJs] = getFeature(feature,1);
    Sektion = linspace(1,1,19);
    Sektion = Sektion'
end

 maximum = max(Sektion);
 Tidsenhed=[];
 DJ = [];
% [data,Variables,Tidsenhed,DJ,Scene] = getIntervalGeneric(Matrix,feature,Interval,dataset)

% over1(k,p-2)=sum(Matrix{s,1}(3,x2)>1)*100/size(Matrix{s,1}(3,x2),2);
%              over1_5(k,p-2)=sum(Matrix{s,1}(3,x2)>1.5)*100/size(Matrix{s,1}(3,x2),2);
%              medianHCDF(d)=nanmedian(Matrix{s,1}(3,x2));



AntalDJs = size(Matrix,1);
    Kolonner = sum(Matrix{1,1}(1,:)<=(Matrix{1,1}(1,1)+Interval)+0.0001);
    AntalUnikDJs = AntalDJs/maximum;
    k=0;
    o=0:(maximum-1);
    load stages
    raekker = size(Matrix{1,1},1);
  
    % tidsintervaller
%     clear Matrixtid
%     load 'Matrixtid'
    % Matrixtid er tempo-Matrixen, den definerer intervallerne-
    
    for w=1:size(Matrixtid,1)
    
        lengdeSet(w) = floor((Matrixtid{w,1}(1,end)-Matrixtid{w,1}(1,1))/Interval);
        
    end
    
 
    
for i=1:AntalUnikDJs
    
    R=i+AntalUnikDJs*o;
    TidSet = 0;

  for s=R
      
      if lengdeSet(s)==0
          
      elseif lengdeSet(s)>0
          
          %sørger for at nulstille første tid.
          
          Matrix{s,1}(1,:) = Matrix{s,1}(1,:)-Matrix{s,1}(1,1);
         
        for t=0:(lengdeSet(s)-1)
        
            k=1+k;
            
            x1 = find(Matrix{s,1}(1,:)>=(t*Interval)&Matrix{s,1}(1,:)<=((t+1)*Interval));
        
        for p = 3:raekker
            
                    if size(Matrix{s,1},2)==1
                        Data(k,p-2) = 0;
                    else
                        over1(k,p-2)=sum(Matrix{s,1}(3,x1)>1)*100/size(Matrix{s,1}(3,x1),2);
                        over1_5(k,p-2)=sum(Matrix{s,1}(3,x1)>1.5)*100/size(Matrix{s,1}(3,x1),2);
                        medianHCDF(k,p-2)=nanmedian(Matrix{s,1}(3,x1));
                    end
                    
        end
        
        TidSet = TidSet + 1;
        Tidsenhed(k) = TidSet;
    Scene(k) = sceneRead(i);
    listeI(k) = i;
    
        end
    
    t=lengdeSet(s);
    k=1+k;
    x2 = find(Matrix{s,1}(1,:)>=(t*Interval));
    
    for p = 3:raekker
            
        if size(Matrix{s,1},2)==1
            over1(k,p-2)= 0;
             over1_5(k,p-2)= 0;
             medianHCDF(d)= 0;
        else
             over1(k,p-2)=sum(Matrix{s,1}(3,x2)>1)*100/size(Matrix{s,1}(3,x2),2);
             over1_5(k,p-2)=sum(Matrix{s,1}(3,x2)>1.5)*100/size(Matrix{s,1}(3,x2),2);
             medianHCDF(k,p-2)=nanmedian(Matrix{s,1}(3,x2));
        end
    end
        
    TidSet = TidSet + 1;
    Tidsenhed(k) = TidSet;
   % DJ(k) = DJliste(i);
    Scene(k) = sceneRead(i);
    listeI(k) = i;
      
     % else
          
%     t=lengthEnheder{s,1}+1
%     k=1+k;
%     MedianForInterval(k) = nanmedian(Matrix{i,1}(3,(1+(t-1)*lengthEnheder{i,1}):end));
%     TidSet = TidSet + 1;
%     Tidsenhed(k) = TidSet;
%     DJ(k) = DJliste(i);
%     Scene(k) = sceneRead(i);
      end
      end
end

data = [over1,over1_5,medianHCDF]
Tidsenhed=Tidsenhed';
DJ=DJ';
% t = table(DJlangliste,data)
HCDFVariables = {'HCDFover1';'HCDFover1_5';'Median'}




