image thumbnail


version (2.01 KB) by Guy
Change all the elements on the main diagonal of a logical sparse matrix to 0.


Updated 27 Aug 2009

View License

Because of memory constraints, it is often impossible to change by subscript all the elements of a large sparse matrix to zero. This leads to changing the elements in a loop, which is horrendously slow.
This mex solves that problem.
Usage: B = mexSparseLogical0Diag(A).

This problem is very common when dealing with adjacency matrices used in clustering - an adjacency matrix is a logical matrix, where the main diagonal is all zeros (no element is a neighbour of itself).

Cite As

Guy (2022). mexSparseLogical0Diag (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!