Sparse and Automatic Accumulation

The sparse function is normally used to create sparse matrices but it has a trick up its sleeve! ¬†This post reveals one of my favorite MATLAB tricks. When used with the tuple syntax, sparse(i,j,v) or sparse(i,j,v,m,n), any repeated (i,j) elements are automatically accumulated! In other words, the sparse function automatically sums any values that are… Continue reading »