%% Specify Density
% Create a random 500-by-1000 sparse matrix with density 0.1. The matrix has approximately 0.1*500*1000 = 50000 uniformly distributed nonzero entries.

R = sprand(500,1000,0.1);

% Show the exact number of nonzero elements in the matrix R.

n = nnz(R)

%
% Copyright 2020 The MathWorks, Inc.