diff options
author | Suraj Yerramilli | 2015-06-06 00:18:37 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-06-06 00:18:37 +0530 |
commit | a54aef7be7f1db6aca3588719832751dd4ce00d7 (patch) | |
tree | 19af4ebd37a6551761ef57e0d1a26bcb5df4cfcc | |
parent | 6771e27e52fbf687260d8df3bb3c8613352bc0d4 (diff) | |
download | SysID-R-code-a54aef7be7f1db6aca3588719832751dd4ce00d7.tar.gz SysID-R-code-a54aef7be7f1db6aca3588719832751dd4ce00d7.tar.bz2 SysID-R-code-a54aef7be7f1db6aca3588719832751dd4ce00d7.zip |
Added simulation method
-rw-r--r-- | R/sim.R | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,2 +1,20 @@ #' @export -sim <- function(x) useMethod("sim")
\ No newline at end of file +sim <- function(x) useMethod("sim") + +#' @export +sim.arx <- function(model,input){ + na <- length(model$A) - 1; nk <- model$ioDelay; + nb <- length(model$B) - nk + n <- max(na,nb+nk) + + y <- matrix(rep(0,length(input)+n),nrow=n) + u <- matrix(c(rep(0,n),input),nrow=n) + # padLeftZeros <- function(x) c(rep(0,n),x) + # u <- apply(input,2,padLeftZeros) + + for(i in n+1:length(input)){ + reg <- cbind(-y[i-1:na,],u[i-nk:nb1,]) + y[i] <- reg%*%coef + } + return(y[n+1:length(input),,drop=F]) +}
\ No newline at end of file |