function z=largestSmaller(x,y)

%Input x is an ascending array
%Input y is a scalar
%This function finds the largest value in x that is smaller than y.

for tmp=x(end:-1:1)'
    if tmp<y
        z=tmp;
        return;
    end
end

z=[];
end