function ye = fext(y,M)
% gh = fext(fh,M)
% extend frequency vector to length M by inserting zeros for higher frequencies
% corresponds to "upsampling" in time domain

N = length(y);
s = size(y);
y = y(:);            % use column vector
if M<N
  error('must have M>=length(fh)')
end
if mod(N,2)==0 
  ye = [y(1:N/2);y(N/2+1)/2;zeros(M-N-1,1);y(N/2+1)/2;y((N/2+2):N)];
else
  ye = [y(1:(N+1)/2);zeros(M-N,1);y((N+3)/2:N)];
end
if s==[1,N]          % if y was row vector return row vector
  ye = ye.';
end
