%% Calculate Structural Rank of Matrix
% Calculate the structural rank of a 2-by-4 matrix.

A = [1 0 2 0
     2 0 4 0];
A = sparse(A);
rs = sprank(A)

%
% Compare the structural rank to the regular rank calculation.

rf = rank(full(A))

% For this matrix, the structural rank is 2 since two of the columns are nonzero. But the actual rank of the matrix is 1 since the columns are multiples of each other.
% Copyright 2019 The MathWorks, Inc.