Skip to content

spalloc

sparse · scripts/sparse/spalloc.m

S = spalloc (m, n, nz)
S = spalloc (m, n, nz, typename)

Allocate an m-by-n all-zero sparse matrix with room reserved for nz
nonzero entries.  Optional typename is "double" (default), "single",
or "logical" (MATLAB R2025a+).  If nz is 0, storage is reserved for 1
entry (same as sparse (... , 0)), matching MATLAB R2026a.

Decision: the 2-argument Octave-style form is rejected with
MATLAB:minrhs (R2026a requires m, n, nz).  This M-file shadows the
older C++ builtin that accepted 2 arguments.