function [SandwichedQRS, CorresWABP] = sandwich(ANN_GQRS, ANN_WABP)

SandwichedQRS=[];
CorresWABP=[];

i=1;
Right=smallestGreater(ANN_WABP,ANN_GQRS(i));
if ~isempty(Right) && ANN_GQRS(i+1)>Right
    SandwichedQRS = [SandwichedQRS; ANN_GQRS(i)];
    CorresWABP = [CorresWABP; Right];
end

for i=2:length(ANN_GQRS)-1
    Right=smallestGreater(ANN_WABP,ANN_GQRS(i));
    Left=largestSmaller(ANN_WABP,ANN_GQRS(i));
    if ~isempty(Right) && ~isempty(Left) && ANN_GQRS(i+1)>Right && ANN_GQRS(i-1)<Left
        SandwichedQRS = [SandwichedQRS; ANN_GQRS(i)];
        CorresWABP = [CorresWABP; Right];
    end
end

i=length(ANN_GQRS);
Left=largestSmaller(ANN_WABP,ANN_GQRS(i));
if ~isempty(Left) && ANN_GQRS(i-1)<Left
    SandwichedQRS = [SandwichedQRS; ANN_GQRS(i)];
    if Left < ANN_WABP(end)
        Right_tmp = smallestGreater(ANN_WABP, Left);
        CorresWABP = [CorresWABP; Right_tmp];
%     else
%         CorresWABP = [CorresWABP, nan];
    end
end

end