function sp=imf_shft1(s);

ds=diff(s);
mj = [];

N=length(s);

for k=1:N-2
   if (ds(k)>0 & ds(k+1)<0)   
      mj=[mj k+1];
   end
   
   if (ds(k)>0 & ds(k+1)==0)
      mj=[mj k+1];
   end
   
   if (ds(k)==0 & ds(k+1)<0)
      mj=[mj k+1];
   end
end

if length(mj)~=0
    if s(2)>s(1)
       s(1)=s(mj(1));
    end
    if s(N-1)>s(N)
       s(N)=s(mj(length(mj)));
    end
end

mj=[1 mj N];

sp=spline(mj,s(mj),1:N);