function [ReturnCategory,HR_Category ] =   findCompatibleData(RetData,CatgoryStart ,CatgoryEnd,Herd_Rate_ijt_tot)




    ReturnCategory = nan(size(RetData));
    HR_Category    = nan(size(RetData));


    for tt=1:size(RetData,1)


        for ii=1:size(RetData,2)

            if  RetData(tt,ii)>=CatgoryStart && RetData(tt,ii)<CatgoryEnd

               ReturnCategory(tt,ii) =  RetData(tt,ii);
               HR_Selected           =  squeeze(Herd_Rate_ijt_tot(:,ii,tt));
               HR_Category(tt,ii)    =  nanmean(HR_Selected);

            end 
        end
    end



end


