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: randomizer_bin_und.m
    path of file: ./repos/fieldtrip/external/bct
    
    the code of the file until where you have to start completion: function [R] = randomizer_bin_und(R,alpha)
%RANDOMIZER_BIN_UND     Random graph with preserved in/out degree distribution

    
function [R] = randomizer_bin_und(R,alpha)
%RANDOMIZER_BIN_UND     Random graph with preserved in/out degree distribution
%
%   R = randomizer_bin_und(A,alpha);
%
%   This function randomizes a binary undirected network, while preserving 
%   the degree distribution. The function directly searches for rewirable 
%   edge pairs (rather than trying to rewire edge pairs at random), and 
%   hence avoids long loops and works especially well in dense matrices.
%
%   Inputs:     A,          binary undirected connection matrix
%               alpha,      fraction of edges to rewire
%
%   Outputs:    R,          randomized network
%
%   References: Maslov and Sneppen (2002) Science 296:910
%
%
%   Jonathan Power, WUSTL. 3/1/10.

%#ok<*ASGLU>

% make binary
R=ceil(R);

% ensure that matrix is binary
if (max(R(:))~=1) || (min(R(:))~=0)
    error('Matrix should be binary');
end