# latex command for diagonal matrix of this kind

Could anyone give me code for this matrix generation?

• Do you want a generic command which autogenerates this, or do you just want to know how to produce it? \begin{bmatrix}d_{1} & & \\ & \ddots & \\ & & d_{r}\end{bmatrix} would do – Au101 Nov 5 '16 at 20:23

You can do this very simply with a bmatrix and \ddots for the diagonal dots. The b in bmatrix is for the (square) brackets. pmatrix would give you parentheses, Bmatrix would give you braces and vmatrix and Vmatrix give you single and double vertical lines (respectively).
\documentclass{article}
$D = \begin{bmatrix} d_{1} & & \\ & \ddots & \\ & & d_{r} \end{bmatrix}$