>> diag(1:5) ans = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 |
>> a=(1:9)'*(1:9); >> diag(a) ans = 1 4 9 16 25 36 49 64 81 |
>> a=(1:9)'*(1:9); >> diag(diag(a)) ans = 1 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 25 0 0 0 0 0 0 0 0 0 36 0 0 0 0 0 0 0 0 0 49 0 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 81 |