| Embedded MATLAB Function4

    function u = hledani_matrix(H,x)

    a=1; b=max(size(H));
    u=zeros(size(x));

    for j=1:size(x,2)
        for i=1:size(x,1)
            leva=a;
            prava=b;
            xij=x(i,j);
            while (prava-leva)>1
                stred=ceil((leva+prava)/2);
                if xij >= H(stred)
                   leva=stred;
                else
                   prava=stred;
                end
            end
            h_left=H(leva);
            u(i,j)=(xij-h_left)/(H(prava)-h_left)+leva;
        end
    end