function [meshelenew]=rmvnod(L,meshele,meshnod)
% [meshelenew]=rmvnod(L,meshele,meshnod);
% Remove selected Nodes and all of the nodes triangles from the grid
% L = min and max for x,y axis
disp(['Click on nodes to be removed'])

x = meshnod(:,2);
y = meshnod(:,3);
meshnod(:,1)= [1:length(meshnod(:,1))]';
clf
hold off
meshtri = meshele(:,:);
meshtri(:,1) = meshtri(:,4);
x4 = meshtri';
y4 = meshtri';
x4(:) = x(meshtri');
y4(:) = y(meshtri');
fill(x4,y4,'w')
axis('equal')
axis(L)
title('Click on nodes to be removed')


pbquit = uicontrol(gcf,'Style','radio','String','QUIT','Value',0 ...
 ,'units','normalized','position',[.02 .045 .107 .047] );

drawnow

while (1)
[xin, yin] = ginput(1);
drawnow
if get(pbquit,'value')
  disp('  QUIT movenod')
  break
end

d = (x-xin).^2+(y-yin).^2;
nod1 = find(d==min(d));

l =find(meshele(:,2)~=nod1 & meshele(:,3)~=nod1 & meshele(:,4)~=nod1 ) ;
meshele=meshele(l,:);
meshele(:,1) = [1:length(l)]';



meshtri = meshele(:,:);
meshtri(:,1) = meshtri(:,4);
x4 = meshtri';
y4 = meshtri';
x4(:) = x(meshtri');
y4(:) = y(meshtri');
fill(x4,y4,'w')
axis('equal')
axis(L)
title('Click on nodes to be removed')
drawnow

end

meshelenew = meshele;
hold off

disp(['done with rmvnod'])
delete(pbquit)


