summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-06-04 00:12:46 +0530
committerSuraj Yerramilli2015-06-04 00:12:46 +0530
commitb53df53ac864cf26507b4c7e49949b89f691447a (patch)
treee8f5b42c4dd5efff4a0d54ad690f82246262af23
parented71be1ff54ea4eac16bf22785e207e7c45d6d4f (diff)
downloadSysID-R-code-b53df53ac864cf26507b4c7e49949b89f691447a.tar.gz
SysID-R-code-b53df53ac864cf26507b4c7e49949b89f691447a.tar.bz2
SysID-R-code-b53df53ac864cf26507b4c7e49949b89f691447a.zip
Corrected the etfe function
-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