Main Content

distributed.spalloc

Allocate space for sparse distributed matrix

Syntax

SD = distributed.spalloc(M,N,nzmax)

Description

SD = distributed.spalloc(M,N,nzmax) creates an M-by-N all-zero sparse distributed matrix with room to hold nzmax nonzeros.

Examples

Allocate space for a 1000-by-1000 sparse distributed matrix with room for up to 2000 nonzero elements, then define several elements:

N = 1000;
SD = distributed.spalloc(N,N,2*N);
for ii=1:N-1
    SD(ii,ii:ii+1) = [ii ii];
end

Version History

Introduced in R2009b