diff options
-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 |