diff options
author | Suraj Yerramilli | 2015-06-09 13:09:16 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-06-09 13:09:16 +0530 |
commit | 1108f50ab77bc71f118022f305ef99abff9749c9 (patch) | |
tree | 265adcf5d03420daba6e119a0f8ed8856d755c2e /R | |
parent | 5ad4c3a2305c223ab030e9f0a3d48f1f32295246 (diff) | |
download | SysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.tar.gz SysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.tar.bz2 SysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.zip |
Minor Corrections
Diffstat (limited to 'R')
-rw-r--r-- | R/sim.R | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -11,7 +11,7 @@ sim.default <- function(model,input,sigma=0,seed=NULL){ #' Simulate the response of an ARX system, given the input #' #' @param model an object of class \code{arx} containing the coefficients -#' @param input a vector/matrix containing the input +#' @param input a vector/matrix/idframe containing the input #' @param sigma standard deviation of the innovations (Default= \code{0}) #' @param seed integer indicating the seed value of the random number generator #' @@ -33,12 +33,20 @@ sim.default <- function(model,input,sigma=0,seed=NULL){ #' @export sim.arx <- function(model,input,sigma=0,seed=NULL){ na <- length(model$A) - 1; nk <- model$ioDelay; - nb <- length(model$B) - nk; nb1 <- nb+nk + nb <- length(model$B) - 1; nb1 <- nb+nk n <- max(na,nb1) - coef <- matrix(c(model$A[-1],model$B),nrow=na+nb1) + coef <- matrix(c(model$A[-1],model$B),nrow=na+nb1) + + if(class(input)=="idframe"){ + uk <- input$input[,1] + } else if(class(input) %in% c("matrix","data.frame")){ + uk <- input[,1] + } else if(is.numeric(input)){ + uk <- input + } y <- rep(0,length(input)+n) - u <- c(rep(0,n),input$input[,1]) + u <- c(rep(0,n),uk) if(!is.null(seed)) set.seed(seed) |