Skip to content

Instantly share code, notes, and snippets.

@clbarnes
Created November 13, 2015 16:04
Show Gist options
  • Select an option

  • Save clbarnes/8255eac7122db12e6131 to your computer and use it in GitHub Desktop.

Select an option

Save clbarnes/8255eac7122db12e6131 to your computer and use it in GitHub Desktop.
A proposed function for the Brain Connectivity Toolbox to remove self-loops from an input matrix
function W_ = remove_self_loops(W)
% REMOVE_SELF_LOOPS Removal of self-self connections from an input
% matrix
%
% W_ = remove_self_loops(W);
%
% Return a copy of the input matrix with all self-self connections
% removed (i.e. the primary diagonal set to all 0s).
%
% Inputs: W binary or weighted connectivity matrix
%
% Output: W_ output connectivity matrix
%
%
% Chris Barnes, HHMI Janelia Research Campus, 2015
% Modification History:
% Nov 2015: Original
W_ = W.*(1-eye(length(W)));
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment