diff options
-rw-r--r-- | R/idframe.R | 42 | ||||
-rw-r--r-- | README.md | 2 |
2 files changed, 39 insertions, 5 deletions
diff --git a/R/idframe.R b/R/idframe.R index 522f351..0040629 100644 --- a/R/idframe.R +++ b/R/idframe.R @@ -3,10 +3,44 @@ idframe <- function(output=data.frame(numeric(0)),input=data.frame(numeric(0)), type=c("time","freq")[1],Ts = 1, outputnames = colnames(output),inputnames = colnames(input), t.start=0,t.end=NA, timeUnit = "seconds", - frequencies = NA, freqUnit= NA){ - out <- list(output=output,input=input,type=type,Ts=Ts) - class(out) <- "idframe" - return(out) + frequencies = NA, freqUnit= "Hz"){ + + dat <- list(output=data.frame(output),input=data.frame(input),type=type,Ts=Ts) + n <- dim(output)[1] + p <- dim(output)[2];m <- dim(input)[2] + + if(outputnames==NULL) + outputnames <- sapply(1:p,FUN=function(x){paste("y",as.character(x),sep="")}}) + + if(inputnames==NULL) + inputnames <- sapply(1:m,FUN=function(x){paste("u",as.character(x),sep="")}}) + + colnames(dat$output) <- outputnames + colnames(dat$input) <- inputnames + + if(type=="freq"){ + + if(is.na(frequencies)){ + frequncies <- seq(0,2*pi,length=n) + } + + dat$frequencies <- frequencies + dat$freqUnit <- freqUnit + + } else { + + if(is.na(t.end)) { + t.end <- t.start + Ts*(n-1) + } else { + out$Ts <- (t.end-t.start)/(n-1) + } + + out$tStart <- t.start; out$tEnd <- t.end + out$timeUnit <- timeUnit + } + + class(dat) <- "idframe" + return(dat) } # print method for idframe class @@ -1,3 +1,3 @@ -# Rsysid - System Identification in R +# sysid - System Identification in R The package provides functions for constructing mathematical models of dynamic systems from measured input-output data. It lets you create and use models of dynamic systems not easily modeled from first principles or specifications. You can use time-domain and frequency-domain input-output data to identify discrete-time input-output models, transfer functions and state space models.
\ No newline at end of file |