function [elat,out] = extend90(lat,in);


%extends a meridional vector to the poles

if (lat(1) > lat(end))
    
    error('this program is only designed for increasing latitude vectors');
end

lat=g2c(lat); %make it a column vector

elat= [-90 ; lat; 90]; %extended latitude vector

out = [in(1) + (in(1)-in(2)) * ((lat(1) + 90) / (lat(2)-lat(1)))                  ;
                          in(:)                                                  ;
    in(end) + (in(end) - in(end-1)) * ( 90 - lat(end)) / (lat(end) -lat(end-1)) ];