function [ iv ] = myinterp1n2( X, v )
%MYINTERP1N returns the 1-D interpolated value
%   using 'nearest'. X is the vector and v is the
%   value to be interpolated.
%   Minas Spetsakis Mar. 2021

vr = round(v);
N  = length(X);
vr = (vr<1) + N*(vr>N) + vr.*(vr>=1).*(vr<=N);
iv = X(vr);

end

