diff options
author | Suraj Yerramilli | 2015-06-06 00:46:01 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-06-06 00:46:01 +0530 |
commit | 9044493a051de8cd30cc22123dc851da0aa87349 (patch) | |
tree | 7f22ebd0665d78e7adf4ffe0184406bf54f4158e | |
parent | cb696cfcc830e10b6518cf1d768884e967bc84b3 (diff) | |
download | SysID-R-code-9044493a051de8cd30cc22123dc851da0aa87349.tar.gz SysID-R-code-9044493a051de8cd30cc22123dc851da0aa87349.tar.bz2 SysID-R-code-9044493a051de8cd30cc22123dc851da0aa87349.zip |
Corrected errors in code
-rw-r--r-- | R/sim.R | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -4,17 +4,18 @@ sim <- function(x) useMethod("sim") #' @export sim.arx <- function(model,input,sigma=0){ na <- length(model$A) - 1; nk <- model$ioDelay; - nb <- length(model$B) - nk - n <- max(na,nb+nk) + nb <- length(model$B) - nk; nb1 <- nb+nk + n <- max(na,nb1) + coef <- matrix(c(model$A[-1],model$B),nrow=na+nb1) - y <- matrix(rep(0,length(input)+n),nrow=n) - u <- matrix(c(rep(0,n),input),nrow=n) + y <- rep(0,length(input)+n) + u <- c(rep(0,n),input) # 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,]) + reg <- matrix(c(-(y[i-1:na]),u[i-nk:nb1]),ncol=na+nb1) y[i] <- reg%*%coef + rnorm(1,sd = sigma) } - return(y[n+1:length(input),,drop=F]) + return(y[n+1:length(input)]) }
\ No newline at end of file |