直接用spy命令就行。
以下是它的参数解释:
spy Visualize sparsity pattern.
spy(S) plots the sparsity pattern of the matrix S.
spy(S,'LineSpec') uses the color and marker from the line
specification string 'LineSpec' (See PLOT for possibilities).
spy(S,markersize) uses the specified marker size instead of
a size which depends upon the figure size and the matrix order.
spy(S,'LineSpec',markersize) sets both.
spy(S,markersize,'LineSpec') also works.
Reference page in Help browser