%% Save Memory Using Sparse Storage
% Create a 10,000-by-10,000 full storage identity matrix.

A = eye(10000);
whos A

% This matrix uses 800-megabytes of memory.
%
% Convert the matrix to sparse storage.

S = sparse(A);
whos S

% In sparse form, the same matrix uses roughly 0.25-megabytes of memory. In this case, you can avoid full storage completely by using the speye function, which creates sparse identity matrices directly.
% Copyright 2015 The MathWorks, Inc.