In reply to O.O.

Use the Spearman correlation matrix as the input matrix. For my example, you would change the line
corr = corr(Y);
to
corr = corr(Y, "spearman");