function ind = mesh_commonvertex(f, g)
% f is a larger mesh than g. 
% mesh_commonvertex finds the index of f.vertices that is in g.vertices


coordf=f.vertices;
coordg=g.vertices;

n=size(coordf,1);
m=size(coordg,1);

ind=zeros(m,1);

for i=1:m
    p=coordg(i,:);
    repp=repmat(p,n,1);
    diff=sqrt(sum((repp-coordf).^2,2));
    [c, minind] =min(diff);
    ind(i)=minind;
end;