CrossMatrix[r]
gives a matrix whose elements are 1 in a centered cross-shaped region that extends r positions along each index direction, and are 0 otherwise.
CrossMatrix[r,w]
gives a w×w matrix containing a cross-shaped region of 1s.
CrossMatrix[{r1,r2,…},…]
yields an array whose elements are 1 in a centered cross-shaped region that extends ri positions in the i index direction.


CrossMatrix
CrossMatrix[r]
gives a matrix whose elements are 1 in a centered cross-shaped region that extends r positions along each index direction, and are 0 otherwise.
CrossMatrix[r,w]
gives a w×w matrix containing a cross-shaped region of 1s.
CrossMatrix[{r1,r2,…},…]
yields an array whose elements are 1 in a centered cross-shaped region that extends ri positions in the i index direction.
Details

- The cross of 1s is always at the center of the region.
- In CrossMatrix[r] or CrossMatrix[{r1,…}] the matrix or array is sized so as to just include all nonzero elements.
- CrossMatrix[All,w] gives a w×w matrix containing a cross shape that is as large as possible.
- CrossMatrix[…,{w1,w2,…}] gives a w1×w2×… array.
- CrossMatrix[{r1,…,rn},w] gives a w×…×w array. »
- CrossMatrix[All,{w1,…,wn}] gives a w1×…×wn array containing a cross-shaped region that is as large as possible.
- Elements of CrossMatrix[r] are 1 if their edit distance from the center is not more than 1.
- The parameter r need not be an integer; in an odd-dimensional array, the cross extends Floor[Abs[r+1/2]] pixels from the origin.
- The lines of the cross have width 1 if the corresponding dimension is odd and width 2 otherwise.
- For integer r, CrossMatrix[r] yields a (2r+1)×(2r+1) matrix. »
Examples
open all close allScope (7)
Properties & Relations (1)
CrossMatrix[r] yields a (2r+1)×(2r+1) matrix:
Neat Examples (1)
History
Text
Wolfram Research (2008), CrossMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/CrossMatrix.html.
CMS
Wolfram Language. 2008. "CrossMatrix." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CrossMatrix.html.
APA
Wolfram Language. (2008). CrossMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CrossMatrix.html
BibTeX
@misc{reference.wolfram_2025_crossmatrix, author="Wolfram Research", title="{CrossMatrix}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/CrossMatrix.html}", note=[Accessed: 07-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_crossmatrix, organization={Wolfram Research}, title={CrossMatrix}, year={2008}, url={https://reference.wolfram.com/language/ref/CrossMatrix.html}, note=[Accessed: 07-August-2025]}