summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-11-01 13:49:06 +0530
committerSuraj Yerramilli2015-11-01 13:49:06 +0530
commitdadec35aa72a6f28ebbfcf70b0e80fe63d711e3e (patch)
treeacc6518a49cbcc89bc525a29fbdbdba8c8a5b55c /R
parent53a494166197e5414399f24b8aa80e2c74493159 (diff)
downloadSysID-R-code-dadec35aa72a6f28ebbfcf70b0e80fe63d711e3e.tar.gz
SysID-R-code-dadec35aa72a6f28ebbfcf70b0e80fe63d711e3e.tar.bz2
SysID-R-code-dadec35aa72a6f28ebbfcf70b0e80fe63d711e3e.zip
Added print method for ARMAX functions
Diffstat (limited to 'R')
-rw-r--r--R/poly.R49
1 files changed, 49 insertions, 0 deletions
diff --git a/R/poly.R b/R/poly.R
index fd1b373..7db046c 100644
--- a/R/poly.R
+++ b/R/poly.R
@@ -27,6 +27,8 @@ checkUnity <- function(x){
print.idpoly <- function(x){
if(x$type=="arx"){
print_arx(x)
+ } else if(x$type=="armax"){
+ print_armax(x)
}
}
@@ -64,3 +66,50 @@ print_arx <- function(obj){
}
}
+print_armax <- function(obj){
+ cat("Discrete-time ARX model: A(q^{-1})y[k] = B(q^{-1})u[k] + C(q^{-1})e[k] \n\n")
+ cat("A(q^{-1}) = ")
+ for(i in seq_along(obj$A)){
+ if(i-1==0){
+ cat(obj$A[i])
+ } else{
+ if(obj$A[i]>0) cat(" + ") else cat("- ")
+
+ if(!(abs(obj$A[i])==1)) cat(abs(obj$A[i]))
+ cat("q^{-",i-1,"}",sep="")
+ }
+ cat("\t")
+ }
+ cat("\n")
+ cat("B(q^{-1}) = ")
+ for(i in seq_along(obj$B)){
+ if(i+obj$ioDelay-1==0){
+ cat(obj$B[i])
+ } else{
+
+ if(!((obj$ioDelay!=0) && (i==1))){
+ if(obj$B[i]>0) cat(" + ") else cat("- ")
+ } else{
+ if(obj$B[i]<0) cat("-")
+ }
+
+ if(!(abs(obj$B[i])==1)) cat(abs(obj$B[i]))
+ cat("q^{-",i+obj$ioDelay-1,"}",sep="")
+ }
+ cat("\t")
+ }
+ cat("\n")
+ cat("C(q^{-1}) = ")
+ for(i in seq_along(obj$C)){
+ if(i-1==0){
+ cat(obj$C[i])
+ } else{
+ if(obj$C[i]>0) cat(" + ") else cat("- ")
+
+ if(!(abs(obj$C[i])==1)) cat(abs(obj$C[i]))
+ cat("q^{-",i-1,"}",sep="")
+ }
+ cat("\t")
+ }
+}
+