diff options
author | Suraj Yerramilli | 2015-06-03 17:07:25 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-06-03 17:07:25 +0530 |
commit | 72e42643b762b2ba5ed8df82f168bf49e927f941 (patch) | |
tree | 494cf72513164c3853cec691ac1b8fdba905f258 /R | |
parent | 4a682bcd0a1fbba1b7424693c7c850f0535ada00 (diff) | |
download | SysID-R-code-72e42643b762b2ba5ed8df82f168bf49e927f941.tar.gz SysID-R-code-72e42643b762b2ba5ed8df82f168bf49e927f941.tar.bz2 SysID-R-code-72e42643b762b2ba5ed8df82f168bf49e927f941.zip |
Improvements to the Bode Plot
Diffstat (limited to 'R')
-rw-r--r-- | R/idframe.R | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/R/idframe.R b/R/idframe.R index 3a118ec..a9aa012 100644 --- a/R/idframe.R +++ b/R/idframe.R @@ -173,14 +173,16 @@ idfrd <- function(response,freq,Ts){ #' @export plot.idfrd <- function(object){ - require(ggplot2);require(reshape2) + require(ggplot2);require(reshape2);require(signal) - mag <- 20*log10(Mod(object$resp)); phase <- Arg(object$resp) - sys_df <- data.frame(Frequency = object$freq,Gain = mag,Phase = phase) + mag <- 20*log10(Mod(object$resp)) + phase <- unwrap(Arg(object$resp)) + sys_df <- data.frame(Frequency = object$freq,Gain = mag,Phase = -phase) melted_sys_df <- melt(sys_df, id.var = c("Frequency")) bode <- ggplot(sys_df, aes(x = Frequency)) + - geom_line() + scale_x_log10() + theme_bw() + geom_line(colour="steelblue") + scale_x_log10() + theme_bw() + + geom_vline(aes(xintercept=max(object$freq),size=1.2)) bode_gain <- bode + aes(y = Gain) bode_phase <- bode + aes(y = Phase) |