User`s guide

11 Functions — Alphabetical List
11-284
To simplify this six-argument call, you can pass scalars for the argument v and one of the
arguments i or j, in which case they are expanded so that i, j, and v all have the same
length.
SC = sparse(i,j,v,m,n) uses nzmax = max([length(i) length(j)]) .
SC = sparse(i,j,v) uses m = max(i) and n = max(j). The maxima are computed
before any zeros in v are removed, so one of the rows of [i j v] might be [m n 0],
assuring the matrix size satisfies the requirements of m and n.
Note: To create a sparse codistributed array of underlying class logical, first create an
array of underlying class double and then cast it using the logical function:
spmd
SC = logical(sparse(m, n, codistributor1d()));
end
Examples
With four workers,
spmd(4)
C = sparse(1000, 1000, codistributor1d())
end
creates a 1000-by-1000 codistributed sparse double array C. C is distributed by its second
dimension (columns), and each worker contains a 1000-by-250 local piece of C.
spmd(4)
codist = codistributor1d(2, 1:numlabs)
C = sparse(10, 10, codist);
end
creates a 10-by-10 codistributed sparse double array C, distributed by its columns. Each
worker contains a 10-by-labindex local piece of C.
Convert a distributed array into a sparse distributed array:
R = rand(1000,'distributed');
D = floor(2*R); % D also is distributed
SD = sparse(D); % SD is sparse distributed