You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bbxflatsegment.m
    path of file: ./repos/iso2mesh
    
    the code of the file until where you have to start completion: function seg=bbxflatsegment(node,loop)
%
% seg=bbxflatsegment(node,loop)
%
% decompose edge loops into flat segments along the x/y/z 
% planes of the bounding box
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2008/04/08
%
% input:   
%    node:  x,y,z coordinates of each node of the mesh

    
function seg=bbxflatsegment(node,loop)
%
% seg=bbxflatsegment(node,loop)
%
% decompose edge loops into flat segments along the x/y/z 
% planes of the bounding box
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2008/04/08
%
% input:   
%    node:  x,y,z coordinates of each node of the mesh
%    loop:  input, a single vector separated by NaN, each segment
%             is a close-polygon consisted by node IDs 
% output:
%    seg:   output, a single vector separated by NaN, each segment
%             is a close-polygon on x/y/z plane 
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

pos=node(loop,:);

% get the bounding box
mi=min(pos);
ma=max(pos);

% extract nodes on the bounding box
idx0=find(abs(pos(:,1)-mi(1))<1e-6)';
idx1=find(abs(pos(:,1)-ma(1))<1e-6)';

idy0=find(abs(pos(:,2)-mi(2))<1e-6)';
idy1=find(abs(pos(:,2)-ma(2))<1e-6)';

idz0=find(abs(pos(:,3)-mi(3))<1e-6)';
idz1=find(abs(pos(:,3)-ma(3))<1e-6)';

% need to be more than 3 points to make a flat polygon

if(length(idx0)<=3) idx0=[]; end