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: modularity_probtune_und_sign.m
    path of file: ./repos/fieldtrip/external/bct
    
    the code of the file until where you have to start completion: function [M q]=modularity_probtune_und_sign(W,qtype,M,p)
%MODULARITY_PROBTUNE_UND_SIGN     Optimal community structure, modularity and degeneracy
%
%   Ci     = modularity_probtune_und_sign(W,   [],Ci0,0.01);
%   Ci     = modularity_probtune_und_sign(W,'sta',Ci0,0.01);
%   [Ci Q] = modularity_probtune_und_sign(W,'sta',Ci0,0.01);
%
%   The optimal community structure is a subdivision of the network into
%   nonoverlapping groups of nodes in a way that maximizes the number of
%   within-group edges, and minimizes the number of between-group edges. 
%   The modularity is a statistic that quantifies the degree to which the

    
function [M q]=modularity_probtune_und_sign(W,qtype,M,p)
%MODULARITY_PROBTUNE_UND_SIGN     Optimal community structure, modularity and degeneracy
%
%   Ci     = modularity_probtune_und_sign(W,   [],Ci0,0.01);
%   Ci     = modularity_probtune_und_sign(W,'sta',Ci0,0.01);
%   [Ci Q] = modularity_probtune_und_sign(W,'sta',Ci0,0.01);
%
%   The optimal community structure is a subdivision of the network into
%   nonoverlapping groups of nodes in a way that maximizes the number of
%   within-group edges, and minimizes the number of between-group edges. 
%   The modularity is a statistic that quantifies the degree to which the
%   network may be subdivided into such clearly delineated groups.
%   High-modularity degeneracy is the presence of many topologically
%   distinct high-modularity partitions of the network.
%
%   This algorithm is inspired by the Kernighan-Lin fine-tuning algorithm
%   and is designed to probabilistically refine a previously detected
%   community by incorporating random node moves into a finetuning
%   algorithm.
%
%   Input:      W,      undirected (weighted or binary) connection matrix
%                       with positive and negative weights
%
%               qtype,  modularity type (see Rubinov and Sporns, 2011)
%                           'sta',  Q_* (default if qtype is not specified)
%                           'pos',  Q_+
%                           'smp',  Q_simple
%                           'gja',  Q_GJA
%                           'neg',  Q_-
%
%               Ci0,    initial community affiliation vector (optional)
%
%               p,      probability of random node moves
%
%
%   Output:     Ci,     refined community affiliation vector
%               Q,      modularity (qtype depend