clear,close all
load worldcoast_gshhg
hold on
clear htopo,htopo=plot(coast(:,1),coast(:,2),'k');

axis_medsea,phys_pose

lon=coast(:,1);
lat=coast(:,2);

minlon=aa(1);
maxlon=aa(2);
minlat=aa(3);
maxlat=aa(4);

clear si,si=find(lon<=minlon);
lon(si)=[];
lat(si)=[];

clear si,si=find(lon>=maxlon);
lon(si)=[];
lat(si)=[];

clear si,si=find(lat<=minlat);
lon(si)=[];
lat(si)=[];

clear si,si=find(lat>=maxlat);
lon(si)=[];
lat(si)=[];

[cual,ind]=min(lon);
lat=[lat(1:ind);nan;lat(ind+1:end)];
lon=[lon(1:ind);nan;lon(ind+1:end)];

for k=3:length(lon)
  if lon(k-1)==nan& lon(k)==nan
    lon(k-1)=[];
    lat(k-1)=[];
  end
end

medlon=lon;
medlat=lat;

figure,plot(lon,lat),phys_posd
axis_medsea
save -mat7-binary mymed.mat medlon medlat