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: rememptychanloc.m
    path of file: ./repos/erplab/functions
    
    the code of the file until where you have to start completion: % PURPOSE: removes any 
    
function
%
% FORMAT:
%
% [ERP serror] = rememptychanloc(ERP);
%
%
% See also borrowchanloc.m
%
%
% *** This function is part of ERPLAB Toolbox ***
% Author: Javier Lopez-Calderon
% Center for Mind and Brain
% University of California, Davis,
% Davis, CA
% 2013

function [ERP serror] = rememptychanloc(ERP)
serror = 0; % ok
if isfield(ERP.chanlocs, 'theta')
        try
                chanok = {ERP.chanlocs.theta};
                exchanArray = find(cellfun('isempty',chanok));
                
                if ~isempty(exchanArray)                        
                        selchannels = find(~ismember_bc2(1:ERP.nchan,exchanArray)); %selected channels
                        nsch = length(selchannels);
                        auxd = ERP.bindata(selchannels,:,:);
                        ERP.bindata = [];
                        ERP.bindata(1:nsch,:,:) = auxd;
                        ERP.nchan   = nsch;
                        namefields  = fieldnames(ERP.chanlocs);
                        nfn = length(namefields);
                        auxfield = {''};
                        
                        for ff=1:nfn
                                auxfield{ff} = {ERP.chanlocs(selchannels).(namefields{ff})};
                        end