summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NAMESPACE1
-rw-r--r--R/idframe.R2
-rw-r--r--R/nonparam.R12
-rw-r--r--man/etfe.Rd12
4 files changed, 25 insertions, 2 deletions
diff --git a/NAMESPACE b/NAMESPACE
index e6eaa0b..87f7cd3 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -9,6 +9,7 @@ S3method(print,tf)
S3method(summary,idframe)
export(dataSlice)
export(detrend)
+export(etfe)
export(idframe)
export(idfrd)
export(impulseest)
diff --git a/R/idframe.R b/R/idframe.R
index 18b5e2c..3a118ec 100644
--- a/R/idframe.R
+++ b/R/idframe.R
@@ -180,7 +180,7 @@ plot.idfrd <- function(object){
melted_sys_df <- melt(sys_df, id.var = c("Frequency"))
bode <- ggplot(sys_df, aes(x = Frequency)) +
- geom_line() + scale_x_log10()
+ geom_line() + scale_x_log10() + theme_bw()
bode_gain <- bode + aes(y = Gain)
bode_phase <- bode + aes(y = Phase)
diff --git a/R/nonparam.R b/R/nonparam.R
index 7ddf49b..a9243bc 100644
--- a/R/nonparam.R
+++ b/R/nonparam.R
@@ -101,12 +101,22 @@ spa <- function(data,npad=255){
# Non-parametric Estimation of Spectral Densities -
# WOSA and Hanning window
gamma <- SDF(temp,method="wosa",sampling.interval = data$Ts,npad=npad)
- out <- list(response = gamma[,2]/gamma[,3],spec=gamma)
+ freq <- seq(from=1,to=ceiling(npad/2),by=1)/ceiling(npad/2)*pi/data$Ts
+ out <- idfrd(response = gamma[,2]/gamma[,3],freq=freq,Ts= data$Ts)
return(out)
}
#' Estimate empirical transfer function
#'
+#' Estimates the emperical transfer function
+#'
+#' @export
etfe <- function(data){
+ require(sapa)
+ temp <- cbind(data$output,data$input)
+ tempfft <- mvfft(temp)/dim(temp)[1]
+ freq <- seq(from=1,to=dim(temp)[1],by=1)/dim(temp)[1]*pi/data$Ts
+ out <- idfrd(response=tempfft[,1]/tempfft[,2],freq=freq,Ts=data$Ts)
+ return(out)
}
diff --git a/man/etfe.Rd b/man/etfe.Rd
new file mode 100644
index 0000000..1e0732e
--- /dev/null
+++ b/man/etfe.Rd
@@ -0,0 +1,12 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/nonparam.R
+\name{etfe}
+\alias{etfe}
+\title{Estimate empirical transfer function}
+\usage{
+etfe(data)
+}
+\description{
+Estimates the emperical transfer function
+}
+