summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/idframe.R2
-rw-r--r--R/nonparam.R11
2 files changed, 6 insertions, 7 deletions
diff --git a/R/idframe.R b/R/idframe.R
index 31b0b41..be4f0f2 100644
--- a/R/idframe.R
+++ b/R/idframe.R
@@ -176,7 +176,7 @@ plot.idfrd <- function(object){
require(ggplot2);require(reshape2);require(signal)
mag <- 20*log10(Mod(object$resp))
- phase <- -180/pi*unwrap(Arg(object$resp))
+ phase <- -360/2/pi*unwrap(Arg(object$resp))
sys_df <- data.frame(Frequency = object$freq,Gain = mag,Phase = phase)
melted_sys_df <- melt(sys_df, id.var = c("Frequency"))
diff --git a/R/nonparam.R b/R/nonparam.R
index 892027b..d7a6162 100644
--- a/R/nonparam.R
+++ b/R/nonparam.R
@@ -87,7 +87,6 @@ step <- function(model){
abline(h=0)
}
-#'
#' Estimate frequency response
#'
#' Estimates Frequency Response with fixed frequency resolution using
@@ -112,12 +111,12 @@ spa <- function(data,npad=255){
#'
#' @export
etfe <- function(data){
- require(sapa)
temp <- cbind(as.ts(data$output),as.ts(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=as.complex(tempfft[,1]/tempfft[,2]),freq=freq,
+ freq <- seq(from=1,to=ceiling(dim(tempfft)[1]/2),
+ by=1)/ceiling(dim(tempfft)[1]/2)*pi/data$Ts
+ resp <- as.complex(tempfft[,1]/tempfft[,2])
+ out <- idfrd(response=resp[1:ceiling(length(resp)/2)],freq=freq,
Ts=data$Ts)
return(out)
-}
+} \ No newline at end of file