%% Convert Matrix to Existing Data Type
% Create a 2-by-3 matrix of zeros whose elements are 32-bit unsigned integers.

A = zeros(2,3,'uint32')

% Create a 2-by-2 sparse matrix of the data type double.

p = sparse(2,2,pi)

% Convert A to the same data type and sparsity as the variable p.

B = cast(A,'like',p)

%
% Copyright 2019 The MathWorks, Inc.