# What would be the Mathematica equivalent of sparse in MATLAB?

The sparse function in MATLAB does the following:

S = sparse(i,j,v) generates a sparse matrix S from the triplets i, j, and v such that S(i(k),j(k)) = v(k). The max(i)-by-max(j) output matrix has space allotted for length(v) nonzero elements. sparse adds together elements in v that have duplicate subscripts in i and j. If the inputs i, j, and v are vectors or matrices, they must have the same number of elements. Alternatively, the argument v and/or one of the arguments i or j can be scalars.

I would like to have a fairly equivalent function in Mathematica. Has anyone tried to do this beforehand?

• Isn't SparseArray close enough? – Kuba May 26 '16 at 9:53
• I'm not sure. What questions me is the different output of the Matlab function. – Mirko Aveta May 26 '16 at 10:35
• The output in matlab. It's something different, perhaps because it is compressed. – Mirko Aveta May 26 '16 at 10:55
• I think the difference lays in the compression of the memory. – Mirko Aveta May 26 '16 at 11:01
• Then ask that question :) It is possible that there is someone around who knows both but this is MMA related site so you will gather more attention bringing info about Matlab side yourself. Moreover a motiviation would be good, e.g. specific example which Matlab handles way better than MMA and you want to know why. – Kuba May 26 '16 at 11:12

• @J.M. Yes, I would say so. Yifan designed and implemented GraphPlot and he was using it to demonstrate the origins of some of the matrices from Matrix Market. – Anton Antonov May 26 '16 at 12:41