interpolMatrix: Interpolate matrix

View source: R/utilities_math.R

interpolMatrixR Documentation

Interpolate matrix

Description

Internal soundgen function

Usage

interpolMatrix(m, nr = NULL, nc = NULL, interpol = c("approx", "spline")[1])

Arguments

m

input matrix of numeric values

nr, nc

target dimensions

interpol

interpolation method ('approx' for linear, 'spline' for spline)

Details

Performs a chosen type of interpolation (linear or smooth) across both rows and columns of a matrix, in effect up- or downsampling a matrix to required dimensions

Examples

m = matrix(1:12 + rnorm(12, 0, .2), nrow = 3)
soundgen:::interpolMatrix(m)  # just returns the original
soundgen:::interpolMatrix(m, nr = 10, nc = 7)
soundgen:::interpolMatrix(m, nr = 10, nc = 7, interpol = 'spline')
soundgen:::interpolMatrix(m, nr = 2, nc = 7)
soundgen:::interpolMatrix(m, nr = 2, nc = 2)

# input matrices can have a single row/column
soundgen:::interpolMatrix(matrix(1:5, nrow = 1), nc = 9)
soundgen:::interpolMatrix(matrix(1:5, ncol = 1), nr = 5, nc = 3)

soundgen documentation built on Aug. 14, 2022, 5:05 p.m.