function [ nextx ] = pf_resample_sys( currx, w ,essMin)
%PF_RESAMPLE_LV Systematic or low variance resampling

% YOUR CODE STARTS HERE:



M = size(currx, 3);
%if(ess < essMin)% nicht hier sondern in der plocalize pf. Nach dem resambling alle gewichte auf 

    nextx = zeros(3, 1, M);

    r = rand()*1/M;
    c= w(1);
    i=1;
    for m = 1:M
        U= r+(m-1)*1/M;
            while U>c
                i=i+1;
                c=c+w(i);
            end
            nextx(:,:,m)=currx(:,:,i);
    end
        nextx=currx;

% YOUR CODE END HERE

end

