bode: Function for creating a bode plot from a continuous time...

View source: R/bode.R

bodeR Documentation

Function for creating a bode plot from a continuous time transfer function

Description

The function
1. returns a list with two dataframes, one for the mag plot and the other for the phase plot
2. plots the mag and phase if the argument "pl" is set to TRUE (default)
3. Allows to reduce execution time by setting desired resolution using n (default = 5*10^5)

Usage

bode(wL, wU, fun = tf1)
bode(wL, wU, fun = tf1, pl = T)
bode(wL, wU, fun = tf1, pl = F)
bode(wL, wU, fun = tf1, pl = F, n = 3000)
bode(wL, wU, fun = tf1, n = 3000)

Arguments

wL

Lower limit of frequency window in bode plot. Single numeric value

wU

Upper limit of frequency window in bode plot. Single numeric value

fun

A single argument function describing the transfer function

pl

A single boolean value,(default = TRUE), toggles plot on or off

n

Single numeric value, (default = 5*10^5), decides the resolution of the bode plot

Value

Returns a 2 element list containing dataframes related to magnitude and phase plots

Author(s)

Chitran Ghosal

Examples


##define transfer function
tf <- function(s){
  K <- 0.0016
  w1 <- 2*pi*1000
  w2 <- 2*pi*50000
  return(K*s/((s/w1 + 1)*(s/w2 + 1)))
}

##call bode function
L <- bode(0.1, 10^8, fun = tf)

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.