www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CreateSparseMatrixOfNonzerosWithSpecifiedSizeExample.m
%% Sparse Matrix of Nonzeros with Specified Size % Create a 1500-by-1500 sparse matrix from the triplets |i|, |j|, and % |v|. % Copyright 2015 The MathWorks, Inc. i = [900 1000]; j = [900 1000]; v = [10 100]; S = sparse(i,j,v,1500,1500) %% % When you specify a size larger than |max(i)| -by- |max(j)|, the |sparse| % function pads the output with extra rows and columns of zeros. size(S)