summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-06-09 13:09:16 +0530
committerSuraj Yerramilli2015-06-09 13:09:16 +0530
commit1108f50ab77bc71f118022f305ef99abff9749c9 (patch)
tree265adcf5d03420daba6e119a0f8ed8856d755c2e
parent5ad4c3a2305c223ab030e9f0a3d48f1f32295246 (diff)
downloadSysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.tar.gz
SysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.tar.bz2
SysID-R-code-1108f50ab77bc71f118022f305ef99abff9749c9.zip
Minor Corrections
-rw-r--r--R/sim.R16
-rw-r--r--man/plot.idframe.Rd2
-rw-r--r--man/sim.arx.Rd2
3 files changed, 14 insertions, 6 deletions
diff --git a/R/sim.R b/R/sim.R
index c6565a5..d11b430 100644
--- a/R/sim.R
+++ b/R/sim.R
@@ -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)
diff --git a/man/plot.idframe.Rd b/man/plot.idframe.Rd
index 7c820cf..6454e98 100644
--- a/man/plot.idframe.Rd
+++ b/man/plot.idframe.Rd
@@ -4,7 +4,7 @@
\alias{plot.idframe}
\title{Plotting idframe objects}
\usage{
-\method{plot}{idframe}(object, par = list(mar = c(3, 4, 3, 2)),
+\method{plot}{idframe}(object, par = list(mar = c(3, 4, 2, 2)),
col = "steelblue", ...)
}
\arguments{
diff --git a/man/sim.arx.Rd b/man/sim.arx.Rd
index 9707729..0f23d7d 100644
--- a/man/sim.arx.Rd
+++ b/man/sim.arx.Rd
@@ -9,7 +9,7 @@
\arguments{
\item{model}{an object of class \code{arx} containing the coefficients}
-\item{input}{a vector/matrix containing the input}
+\item{input}{a vector/matrix/idframe containing the input}
\item{sigma}{standard deviation of the innovations (Default= \code{0})}