diff options
author | Suraj Yerramilli | 2016-02-23 15:07:50 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2016-02-23 15:07:50 +0530 |
commit | 4ad38fd49e1b508f45bd1f446bb36cca76873a47 (patch) | |
tree | 52a40d95516720710c630c7547738b0bfdb5dd6f | |
parent | 3604c2e67f3591f9c2459cd2992e42fa7d44db0a (diff) | |
download | SysID-R-code-4ad38fd49e1b508f45bd1f446bb36cca76873a47.tar.gz SysID-R-code-4ad38fd49e1b508f45bd1f446bb36cca76873a47.tar.bz2 SysID-R-code-4ad38fd49e1b508f45bd1f446bb36cca76873a47.zip |
computing noise power spectrum
-rw-r--r-- | R/nonparam.R | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/R/nonparam.R b/R/nonparam.R index 18451f4..0a7e194 100644 --- a/R/nonparam.R +++ b/R/nonparam.R @@ -168,18 +168,22 @@ step <- function(model){ #' data(frf) #' frf <- spa(data) #' +#' @import sapa #' @export spa <- function(data,npad=255){ - require(sapa) temp <- cbind(data$output,data$input) # Non-parametric Estimation of Spectral Densities - # WOSA and Hanning window - gamma <- SDF(temp,method="wosa",sampling.interval = deltat(data), - npad=npad) + gamma <- sapa::SDF(temp,method="wosa",sampling.interval = + deltat(data),npad=npad) freq <- attributes(gamma)$frequency*2*pi - out <- idfrd(response = Conj(gamma[,2])/Mod(gamma[,3]),freq=freq, - Ts= deltat(data)) + resp <- Conj(gamma[,2])/Mod(gamma[,3]) + + # power-spectrum + spec <- gamma[,2] - resp*gamma[,3] + + out <- idfrd(resp,freq,deltat(data),spec) return(out) } |