%% Generate Logical Array of Selected Sparsity
% Generate a logical array of the same sparsity as the selected array.

A = logical(sparse(5,3));
whos A

%

T = true(4,'like',A);
whos T

% The output array T has the same sparse attribute and data-type as the specified array A.
% Copyright 2012 The MathWorks, Inc.