I often have to generate diagonal matrices so I created this simple online utility that does it for me. It lets you generate square and rectangular diagonal matrices of any size you need. It works in the browser and is powered by alien technology from the future.

## Diagonal Matrix Generator Options

## Diagonal Matrix Generator Examples (click to try!)

0.75 0 0 0 0 0 0 0 0 0 0 0.45 0 0 0 0 0 0 0 0 0 0 0.37 0 0 0 0 0 0 0 0 0 0 0.23 0 0 0 0 0 0 0 0 0 0 0.91 0 0 0 0 0 0 0 0 0 0 0.65 0 0 0 0 0 0 0 0 0 0 0.11 0 0 0 0 0 0 0 0 0 0 0.07 0 0 0 0 0 0 0 0 0 0 0.19 0 0 0 0 0 0 0 0 0 0 0.55

4 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0

𝟠 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟚 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟙 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟛 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟡 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟞 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟘 𝟠

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

59 34 25 46 97 35

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

## How Does This Diagonal Matrix Generator Work?

This diagonal matrix generator works entirely in your browser and is written in JavaScript. It uses a modified Kronecker delta function `δ`

to construct a diagonal matrix. If _{ij}`i = j`

, then it puts a diagonal element in the position `m`

of the matrix. If _{ij}`i != j`

, then it puts a zero element in the position `m`

. It can generate square matrices of size _{ij}`n×n`

and rectangular matrices of sizes `n×m`

or `m×n`

. The diagonal elements can be random integers (both negative and positive) or decimal numbers (also both negative and positive). If the diagonal elements are decimal numbers, then you can also specify the precision of these numbers in the options. It can also put custom elements on the diagonal. The custom elements can be entered as a space-separated list of symbols. For example, you can use Greek letters `α β γ δ ε`

as the diagonal elements. In this case, this tool will pick one of the custom elements for each diagonal element via a code snippet `m`

. If the diagonal elements have multiple characters in them, then you can prettify the matrix and neatly align all columns. By default, it uses the space character to separate all matrix columns and the newline character to separate all matrix rows. These characters can also be customized in the options._{ij} = pickOne(['α', 'β', 'γ', 'δ', 'ε'])

### Created by Browserling

This diagonal matrix generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our programmer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.