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: rich_club_bu.m
    path of file: ./repos/fieldtrip/external/bct
    
    the code of the file until where you have to start completion: function [R,Nk,Ek] = rich_club_bu(CIJ,varargin)
%RICH_CLUB_BU        Rich club coefficients (binary undirected graph)
%
%   R = rich_club_bu(CIJ)
%   [R,Nk,Ek] = rich_club_bu(CIJ,klevel)
%
%   The rich club coefficient, R, at level k is the fraction of edges that
%   connect nodes of degree k or higher out of the maximum number of edges
%   that such nodes might share.
%
%   Input:      CIJ,        connection matrix, binary and undirected
%            klevel,        optional input argument. klevel sets the
%                              maximum level at which the rich club
%                              coefficient will be calculated. If klevel is
%                              not included the the maximum level will be
%                              set to the maximum degree of CIJ.
%
%   Output:       R,        vector of rich-club coefficients for levels
%                              1 to klevel.
%                Nk,        number of nodes with degree>k
%                Ek,        number of edges remaining in subgraph with
%                              degree>k
%
%   Reference: Colizza et al. (2006) Nat. Phys. 2:110.

    
function [R,Nk,Ek] = rich_club_bu(CIJ,varargin)
%RICH_CLUB_BU        Rich club coefficients (binary undirected graph)
%
%   R = rich_club_bu(CIJ)
%   [R,Nk,Ek] = rich_club_bu(CIJ,klevel)
%
%   The rich club coefficient, R, at level k is the fraction of edges that
%   connect nodes of degree k or higher out of the maximum number of edges
%   that such nodes might share.
%
%   Input:      CIJ,        connection matrix, binary and undirected
%            klevel,        optional input argument. klevel sets the
%                              maximum level at which the rich club
%                              coefficient will be calculated. If klevel is
%                              not included the the maximum level will be
%                              set to the maximum degree of CIJ.
%
%   Output:       R,        vector of rich-club coefficients for levels
%                              1 to klevel.
%                Nk,        number of nodes with degree>k
%                Ek,        number of edges remaining in subgraph with
%                              degree>k
%
%   Reference: Colizza et al. (2006) Nat. Phys. 2:110.
%
%   Martijn van den Heuvel, University Medical Center Utrecht, 2011

Degree = sum(CIJ);  %compute degree of each node

if nargin == 1
    klevel = max(Degree);
elseif nargin == 2
    klevel = varargin{1};
elseif nargin > 2
    error('number of inputs incorrect. Should be [CIJ], or [CIJ, klevel]')
end