From b53df53ac864cf26507b4c7e49949b89f691447a Mon Sep 17 00:00:00 2001 From: Suraj Yerramilli Date: Thu, 4 Jun 2015 00:12:46 +0530 Subject: Corrected the etfe function --- R/idframe.R | 2 +- R/nonparam.R | 11 +++++------ 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 -- cgit