gjmvanboxtel / gsignal

R implementation of the Octave signal package
GNU General Public License v3.0
22 stars 6 forks source link

pwelch doesn't return a matrix in $spec, when the input is a matrix of one column #6

Closed bnicenboim closed 2 years ago

bnicenboim commented 2 years ago

Hi, I see that if I use a matrix of more than one column, the output in spec is a matrix:

fs <- 256
secs <- 10
freq <- 30
ampl <- 1
t <- seq(0, secs, length.out = fs * secs)

x <- ampl * cos(freq * 2 * pi * t) + runif(length(t))
X <- as.matrix(cbind(x,x))
Pxx <- gsignal::pwelch(X, fs = fs)              # no plot
## returns a matrix
Pxx$spec

I would expect that it would be the case if I use a matrix of one column as well:

Pxx2 <- gsignal::pwelch(X[,1, drop = FALSE], fs = fs)              # no plot
## doesn't return a matrix
Pxx2$spec

but it's not the case. (I used the latest version in github).

gjmvanboxtel commented 2 years ago

Hi,

Thanks for this report. I fixed this in v0.3-5.9000 pushed to Github just now.

Best, Geert