Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get a matrix with a 1 in a selected position and 0s elsewhere
ResourceFunction["UnitMatrix"][m,n,i,j] returns an m×n matrix whose only nonzero entry is a 1 in the (i,j)th position. | |
ResourceFunction["UnitMatrix"][m,i,j] returns ResourceFunction["UnitMatrix"][m,m,i,j]. |
A 3×4 matrix whose only non-zero entry is a 1 in the (2,3) position:
In[1]:= |
Out[1]= |
A 5×5 matrix whose only non-zero entry is a 1 in the (4,2) position:
In[2]:= |
Out[2]= |
This work is licensed under a Creative Commons Attribution 4.0 International License