Skip to content

Instantly share code, notes, and snippets.

@quantombone
Created March 25, 2011 18:08
Show Gist options
  • Save quantombone/887292 to your computer and use it in GitHub Desktop.
Save quantombone/887292 to your computer and use it in GitHub Desktop.
Counting in Matlab using sparse
function count_with_sparse
%Find item co-occurences using sparse
%Tomasz Malisiewicz
item1 = [1 3 1 4 3];
item2 = [2 2 2 1 2];
N = 4;
counts = sparse(item1,item2,1,N,N)
imagesc(full(counts))
title('Counts using Sparse')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment