spconvert
S = spconvert (D) -- build a sparse matrix from coordinate triplets If D is N-by-3, columns are [i j re] and S(i(k),j(k)) = re(k). If D is N-by-4, columns are [i j re im] and S(i(k),j(k)) = re(k)+1i*im(k). Repeated (i,j) pairs accumulate. A trailing row with value 0 is commonly used to force the output size to max(i)-by-max(j). If D is already sparse, spconvert returns D unchanged (MATLAB R2026a).