Learn R Programming

sae (version 1.3)

diagonalizematrix: It constructs a block-diagonal matrix.

Description

Using a n*m matrix A, this function constructs a block-diagonal matrix with dimension (n*ntimes) * (m*ntimes), with all blocks equal to matrix A and the rest of entries equal to 0.

Usage

diagonalizematrix(A, ntimes)

Arguments

A

n*m matrix with the values.

ntimes

number of times.

Examples

Run this code
# NOT RUN {
X <- matrix(data=c(1,2,3,4,5,6), nrow=3, ncol=2)
diagonalizematrix(X,3)
# }

Run the code above in your browser using DataLab