相关代码 |
|
例6-17 nnz函数的应用。 解:在命令窗口中输入如下命令,并按Enter键确认。 >> v=[1 2 5 9 4 1 2 6]; >> S=diag(v,-1) S = 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 6 0 >> NZ=nnz(S) NZ = 8 >> D=nnz(S)/prod(size(S)) D = 0.0988 >>
相关资源 |
|