eye: Some Basic Matrices

Description Usage Arguments Value See Also Examples

View source: R/eye.R

Description

Create basic matrices.

Usage

1
2
3
eye(n, m = n)
ones(n, m = n)
zeros(n, m = n)

Arguments

m, n

numeric scalars specifying size of the matrix

Value

Matrix of size n x m. Defaults to a square matrix if m is missing.

No dropping of dimensions; if n = 1, still returns a matrix and not a vector.

See Also

Diag,

Examples

1
2
3
eye(3)
ones(3, 1)
zeros(1, 3)

Example output

     [,1] [,2] [,3]
[1,]    1    0    0
[2,]    0    1    0
[3,]    0    0    1
     [,1]
[1,]    1
[2,]    1
[3,]    1
     [,1] [,2] [,3]
[1,]    0    0    0

pracma documentation built on Jan. 23, 2021, 5:06 p.m.