function [l] = findnod(L,meshnod)
% l = findnod(L,meshnod);
% Identify node number by pointing and clicking
% L = min and max for x,y axis
% if hold is on then the current plot is used for identification
% l will not include the last node used to stop
disp(['Click on nodes to be located'])

x = meshnod(:,2);
y = meshnod(:,3);
if ~ishold
plot(x,y,'og')
axis('equal')
axis(L)
title('Click on nodes to identify')
figure(gcf)
end
hold on
l=[];


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')
  break
end


d = (x-xin).^2+(y-yin).^2;
nod1 = find(d==min(d));
disp(['node=',int2str(nod1),'    x=', num2str(x(nod1))...
      ,'   y=',num2str(y(nod1))])
plot(x(nod1),y(nod1),'*r')
l=[l ; nod1];

end



 hold off

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

