diff options
author | ashwinrcs | 2016-04-04 17:06:45 +0530 |
---|---|---|
committer | ashwinrcs | 2016-04-04 17:06:45 +0530 |
commit | d624bfd7885bffbeb1782a7e83ffa69bd5a4338e (patch) | |
tree | f7e7f48b826ae58a7fbef61d9b0fceca0257a63e /R | |
parent | 9dde78b9078c50db43d3624d7aa22008c7cd0ef5 (diff) | |
download | SysID-R-code-d624bfd7885bffbeb1782a7e83ffa69bd5a4338e.tar.gz SysID-R-code-d624bfd7885bffbeb1782a7e83ffa69bd5a4338e.tar.bz2 SysID-R-code-d624bfd7885bffbeb1782a7e83ffa69bd5a4338e.zip |
minor change in etfe
Diffstat (limited to 'R')
-rw-r--r-- | R/nonparam.R | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/R/nonparam.R b/R/nonparam.R index 6f79ab1..c5264d2 100644 --- a/R/nonparam.R +++ b/R/nonparam.R @@ -271,18 +271,17 @@ etfe <- function(data,n=128){ n=N } v=seq(1,N,length.out = n) - y_v=y[v] - y_w <- (1/n)*fft(y_v) - if(!is.null(u)){ - u_w <- (1/n)*fft(u[v]) - } - mod_y = Mod(y_w) - mod_u = Mod(u_w) - arg_y = Arg(y_w) - arg_u = Arg(u_w) - G = complex(modulus = mod_y/mod_u, argument = arg_y - arg_u) - frequency <- matrix(seq( 1 , ceiling(n/2) ) * pi / floor(n/2) / samp_period) - out <- idfrd(respData = G[1:ceiling(length(G)/2)],freq=frequency, - Ts=data$Ts) + temp <- cbind(data$output[v,],data$input[v,]) + tempfft <- mvfft(temp)/dim(temp)[1] + G <- comdiv(tempfft[,1],tempfft[,2]) + resp = G[1:ceiling(length(G)/2)] + frequency <- matrix(seq( 1 , ceiling(n/2) ) * pi / floor(n/2) / deltat(data)) + out <- idfrd(respData = resp,freq=frequency,Ts=data$Ts) return(out) +} +comdiv <- function(z1,z2){ + mag1 <- Mod(z1);mag2 <- Mod(z2) + phi1 <- Arg(z1); phi2 <- Arg(z2) + + complex(modulus=mag1/mag2,argument=signal::unwrap(phi1-phi2)) }
\ No newline at end of file |