Control - Documentation

Content
  1. int, Methods
  2. float, Methods
  3. string, Methods
  4. bool, Methods
  5. list, Methods
  6. map, Methods
  7. closure, Methods
  8. complex, Methods
  9. polynomial, Methods
  10. linearSystem, Methods
  11. twoPort, Methods
  12. bodePlot, Methods
  13. bodePlotContent, Methods
  14. plot, Methods
  15. plotContent, Methods
  16. style, Methods
  17. image, Methods
  18. data, Methods
  19. static, Functions

int

Methods:

bode(color, title)

Creates a bode plot content. The arguments are optional.

string()

Returns a string representation of the int.

float

Methods:

bode(color, title)

Creates a bode plot content. The arguments are optional.

string()

Returns a string representation of the float.

string

Methods:

behind(prefix)

Returns the string behind the prefix up to the next newline.

behindList(header)

Returns the lines following behind the header line up to the next empty line.

contains(substr)

Returns true if the string contains the substr.

cut(pos, len)

Returns a substring starting at pos with length len. If len is negative, the rest of the string is returned.

indexOf(substr)

Returns the index of the first occurrence of substr in the string. Returns -1 if not found.

len()

Returns the length of the string.

replace(old, new)

Replaces all occurrences of old with new.

split(sep)

Splits the string at the separator and returns a list of strings.

string()

Returns the string itself.

toFloat()

Parses the string to a float.

toInt()

Parses the string to an int.

toLower()

Returns the string in lower case.

toUpper()

Returns the string in upper case.

trim()

Returns the string without leading and trailing spaces.

bool

Methods:

string()

Returns the string 'true' or 'false'.

list

Methods:

accept(func(item) bool)

Filters the list by the given function. If the function returns true, the item is accepted, otherwise it is skipped.

append(item)

Returns a new list with the given item appended. If a list is to be created by adding element by element, this method is more efficient than using the '+' operator.

binning(start, size, count, indexFunc, valueFunc)

Returns a map with the binning results. The index function must return the index of the bin for a specific element of the list, and the value function must return the value to be added to the bin. If only the number of times a value was in a bin is to be counted, the value function must return the constant one.

binning2d(startX, sizeX, countX, startY, sizeYX, countY, indexFuncX, indexFuncY, valueFunc)

Returns a map with the binning results.

collectBinning()

Sums up a list of binning results to create a total result.

combine(func(item, item) newItem)

Combines the list by the given function. The function is called for each pair of items in the list and the result is added to the new list. The resulting list is one item shorter than the original list.

combine3(func(item, item, item) newItem)

Combines the list by the given function. The function is called for each triplet of items in the list and the result is added to the new list. The resulting list is two items shorter than the original list.

combineN(n, func([item...]) newItem)

Combines the list by the given function. The function is called for each group of n items in the list and the result is added to the new list. The resulting list is n-1 items shorter than the original list.

compact(func(a, b) value)

Returns a new list with the items compacted. The given function is called for each successive pair of items in the list.If the function returns nil, both values are kept, if not, both values are replaced by the returned value.

createInterpolation(func(item) x, func(item) y)

Returns a function that interpolates between the given points.

cross(other_list, func(a,b) newItem)

Returns a new list with the given function applied to each pair of items in the list and the given list. The function is called with an item from the first list and an item from the second list. The length of the resulting list is the product of the lengths of the two lists.

data(name, unit, func(item) x, func(item) y)

Creates a data set. The two functions are called with the list elements and must return the x respectively y values. If the functions are omitted, the list elements themselves must be lists of the form [x,y]. The last 2 arguments are optional.

eval()

Evaluates the list and stores all items in memory.

first()

Returns the first item in the list.

fsm(func(state, item) state)

Returns a new list with the given function applied to the items in the list. The state is initialized with '{state:0}' and the function is called with the state and the item and returns the new state. See also the function 'goto', which helps to create new state maps.

graph(func(item) x, func(item) y)

Creates a scatter plot content. The two functions are called with the list elements and must return the x respectively y values. If the functions are omitted, the list elements themselves must be lists of the form [x,y]. The arguments are optional.

groupByEqual(func(item) key)

Returns a list of lists grouped by the given function. The function is called for each item in the list and the returned value is used as the key for the group. The result is a list of maps with the keys 'key' and 'values'. The 'key' contains the value returned by the function and 'values' contains a list of items that have the same key. This method relies only on the Equal operator to determine if two keys are equal. This way no hash can be computed, which makes this method much slower than the other groupBy methods, if the list is large (O(n²)).

groupByInt(func(item) int)

Returns a list of lists grouped by the given function. The function is called for each item in the list and the returned integer is used as the key for the group. The result is a list of maps with the keys 'key' and 'values'. The 'key' contains the integer returned by the function and 'values' contains a list of items that have the same key.

groupByString(func(item) string)

Returns a list of lists grouped by the given function. The function is called for each item in the list and the returned string is used as the key for the group. The result is a list of maps with the keys 'key' and 'values'. The 'key' contains the string returned by the function and 'values' contains a list of items that have the same key.

iir(func(first_item) first_new_item, func(item, last_new_item) new_item)

Returns a new list with the given functions applied to the items in the list. The first function is called with the first item in the list and returns the first item in the new list. The second function is called with the remaining items in the list as the first argument, and the last new item. For each subsequent item, the function is called with the item and the result of the previous call.

iirApply(map)

Returns a new list with the given filter applied to the items in the list. Works the same as 'iirCombine' except the required functions are taken from the map, stored in the keys 'initial' and 'filter'.

iirCombine(func(first_item) first_new_item, func(i0, i1, last_new_item) new_item)

Returns a new list with the given functions applied to the items in the list. The first function is called with the first item in the list and returns the first item in the new list. The second function is called with the remaining pairs of items in the list as the first two arguments, and the last new item. For each subsequent item, the function is called with the the pair of items and the result of the previous call. The item i0 is the item in front of i1.

indexWhere(func(item) condition)

Returns the index of the first occurrence of the given function returning true. If this never happens, -1 is returned.

last()

Returns the last item in the list.

linearReg(func(item) x, func(item) y)

Returns a map containing the values a and b of the linear regression function y=a*x+b that fits the data points.

map(func(item) newItem)

Maps the list by the given function. The function is called for each item in the list and the result is added to the new list.

mapReduce(initialSum, func(sum, item) sum)

MapReduce reduces the list to a single value. The initial value is given as the first argument. The function is called with the initial value and the first item, and the result is used as the first argument for the second item and so on.

max()

Returns the maximum value of the list.

mean()

Returns the mean value of the list.

merge(other_list, func(a,b) bool)

Returns a new list with the items of both lists combined. The given function is called for the pair of the first, non processed items in both lists. If the return value is true the value of the original list is taken, otherwise the item from the other list. The is repeated until all items of both lists are processed. If the function returns true if a<b holds and both lists are ordered, also the new list is ordered.

min()

Returns the minimum value of the list.

minMax(func(item) value)

Returns the minimum and maximum value of the list. The function is called for each item in the list and the result is compared to the previous minimum and maximum.

movingWindow(func(item) float)

Returns a list of lists. The inner lists contain all items that are close to each other. Two items are close to each other if the given function returns a similar value for both items. Similarity is defined as the absolute difference being smaller than 1.

movingWindowRemove(func([list of items]) bool)

Returns a list of lists. The given remove-function is called with a sublist of items. At every call a new item from the original list is added to the sublist. If the function returns true the first item of the sublist is removed and the function is called again until it returns false. If the function returns false or if the sublist contains only one item, the sublist is added to the result.

multiUse({name: func(item) newItem...})

MultiUse allows to use the list multiple times without storing or recomputing its elements. The first argument is a map of functions. All the functions are called with the list as argument and the result is returned in a map. The keys in the result map are the same keys used to pass the functions.

number(func(n,item) item)

Returns a list with the given function applied to each item in the list. The function is called with the index of the item and the item itself.

order(func(item) value)

Returns a new list with the items sorted in the order of the values returned by the given function. The function is called for each item in the list and the returned values determine the order.

orderLess(func(a, a) bool)

Returns a new list with the items sorted by the given function. The function is called for pairs of items in the list and the returned bool needs to be true if a<b holds.

orderRev(func(item) value)

Returns a new list with the items sorted in the reverse order of the values returned by the given function. The function is called for each item in the list and the returned values determine the order.

present(func(item) bool)

Returns true if the given function returns true for any item in the list.

reduce(func(item, item) item)

Reduces the list by the given function. The function is called with the first two list items, and the result is used as the first argument for the third item and so on.

replaceList(func(list) newItem)

Replaces the list by the result of the given function. The function is called with the list as argument.

reverse()

Returns the list in reverse order.

set(index, item)

Replaces the item at the given index with the given item. Returns the new list.

single()

Returns the first item in the list.

size()

Returns the number of items in the list.

skip(n)

Returns a list without the first n items.

string()

Returns the list as a string.

sum()

Returns the sum of all items in the list. Shorthand for reduce((a,b)->a+b).

top(n)

Returns the first n items of the list.

uniqueInt(func(item) int)

Returns a list of unique integers returned by the given function.

uniqueString(func(item) string)

Returns a list of unique strings returned by the given function.

visit(initial_visitor, func(visitor, item) visitor)

Visits each item in the list with the given function. The function is called with the visitor and the item. An initial visitor is given as the first argument. The return value of the function is used as the new visitor.

map

Methods:

accept(func(key, value) bool)

Accept takes a function as argument and returns a new map with all entries for which the function returns true.

combine(other_map, func(a,b) r)

Combines the two maps with the given funktion to a new map. The function is called for each key that is in both maps. The first argument is the value of the first map and the second argument is the value of the second map. The function must return a value that is used as value in the new map.

eval()

Evaluates the map to a real hash map. This is more efficient if the map has many keys and the associated values are requested often.

get(key)

Returns the value for the given key.

isAvail(key)

Returns true if the key is available in the map.

list()

Returns a list of maps with the key and value of each entry in the map.

map(func(key, value) value)

Map takes a function as argument and returns a new map with the same keys and all values replaced by the function.

put(key, value)

Returns a new map with the given key and value added.

replace(func(map) rep_map)

Calls the given function with the original map as argument and returns a 'replacement' map. The key/values from the 'replacement' map are used to replace the key/values in the original map.

replaceMap(func(map) value)

Takes a function as argument and returns the result of the function. The function is called with the map as argument.

size()

Returns the number of entries in the map.

string()

Returns a string representation of the map.

closure

Methods:

args()

Returns the number of arguments the function takes.

graph(steps)

Creates a graph of the function to be used in the plot command. The argument is optional.

invoke(arg_list)

Invokes the function. The values of the given list are passed to the function as arguments.

complex

Methods:

abs()

Returns the amplitude.

imag()

Returns the imaginary component.

phase()

Returns the phase.

real()

Returns the real component.

polynomial

Methods:

bode(color, title)

Creates a bode plot content. The arguments are optional.

degree()

Calculates the derivative.

derivative()

Calculates the derivative.

normalize()

Calculates the normalized polynomial.

roots()

Returns the roots. If a pair of complex conjugates is found, only the complex number with positive imaginary part is returned.

toLaTeX()

Returns a LaTeX representation of the polynomial.

linearSystem

Methods:

bode(color, title)

Creates a bode plot content. The arguments are optional.

denominator()

Returns the denominator of the transfer function.

derivative()

Calculates the derivative of the transfer function.

evans(k_max)

Creates an evans plot.

gMargin()

Returns the stability frequency (ωₛ with G(jωₛ)=j0-1) and the gain margin given in dB.

loop()

Closes the loop. Calculates the closed loop transfer function G/(G+1).

numerator()

Returns the numerator of the transfer function.

nyquist(neg, wMax)

Creates a nyquist plot content. If neg is true also the range -∞<ω<0 is included. The value wMax gives the maximum value for ω. It defaults to 1000rad/s. The arguments are optional.

nyquistNeg(wMax)

Creates a nyquist plot content with negative ω. The value wMax gives the maximum value for ω. It defaults to 1000rad/s. The argument is optional.

nyquistPos(wMax)

Creates a nyquist plot content with positive ω. The value wMax gives the maximum value for ω. It defaults to 1000rad/s. The argument is optional.

pMargin()

Returns the crossover frequency (ω₀ with |G(jω₀)|=1) and the phase margin.

reduce()

Reduces the linear system.

sim(u(t), tMax, dt)

Simulates the transfer function with the input signal u(t) as input signal. It does not close the loop! If the closed control loop is to be simulated, the instruction is G.loop().sim(t->sin(t), 10). The value tMax gives the maximum time for the simulation. The value dt is the step with which defaults to 1e-5. The last argument is optional.

simStep(tMax, dt)

Simulates the transfer function with the step function as input signal. It does not close the loop! If the closed control loop is to be simulated, the instruction is G.loop().simStep(10). The value tMax gives the maximum time for the simulation. The value dt is the step with which defaults to 1e-5. The last argument is optional.

stringPoly()

Creates a string representation of the linear system.

toLaTeX()

Returns a LaTeX representation of the linear system.

twoPort

Methods:

cascade(tp)

Returns a series-series connection.

currentGain(load)

Returns the current gain.

getA()

Returns the A-parameters.

getC()

Returns the C-parameters.

getH()

Returns the H-parameters.

getY()

Returns the Y-parameters.

getZ()

Returns the Z-parameters.

inputImp(load)

Returns the input impedance.

inputImpOpen()

Returns the open circuit input impedance.

outputImp(load)

Returns the output impedance.

outputImpOpen()

Returns the open circuit output impedance.

parallel(tp)

Returns a parallel-parallel connection.

parallelSeries(tp)

Returns a parallel-series connection.

series(tp)

Returns a series-series connection.

seriesParallel(tp)

Returns a series-parallel connection.

voltageGain(load)

Returns the voltage gain.

voltageGainOpen()

Returns the open circuit voltage gain.

bodePlot

Methods:

aBounds(min, max)

Sets the amplitude bounds.

ampModify(function)

The given function gets the amplitude plot and must return the modified amplitude plot.

amplitude()

Returns the amplitude plot.

file(filename)

Enables a file download.

frame(color)

Sets the frame color.

grid(color)

Adds a grid. The argument is optional.

outputSize(width, height)

Sets the svg-output size.

pBounds(min, max)

Sets the phase bounds.

phase()

Returns the phase plot.

phaseModify(function)

The given function gets the phase plot and must return the modified phase plot.

textSize(size)

Sets the text size.

wBounds(min, max)

Sets the frequency bounds.

bodePlotContent

Methods:

latency(latency)

Adds a latency to the bode plot .

line(color, title)

Sets the line style and title. The last argument is optional.

title(str)

Sets a string to show in the legend.

plot

Methods:

add(plotContent)

Adds a plot content to the plot.

borders(left, right)

Sets the width of the left and right border measured in characters.

file(name)

Enables a file download.

frame(color)

Sets the frame color.

grid(color)

Adds a grid. The argument is optional.

inset(xMin, xMax, yMin, yMax)

Converts the plot into an inset that can be added to another plot.

labels(xLabel, yLabel)

Sets the axis labels.

legendPos(x, y)

Sets the position of the legend.

outputSize(width, height)

Sets the svg-output size.

protectLabels()

Autoscaling protects the labels.

textSize(size)

Sets the text size.

title(title)

Sets the title.

xBounds(xMin, xMax)

Sets the x-bounds.

xDate()

Enables date scaling of x-Axis.

xLabel(label)

Sets the x-label.

xLin()

Enables linear scaling of x-Axis.

xLog()

Enables log scaling of x-Axis.

xdB()

Enables dB scaling of x-Axis.

yBounds(yMin, yMax)

Sets the y-bounds.

yDate()

Enables date scaling of y-Axis.

yLabel(label)

Sets the y-label.

yLin()

Enables linear scaling of y-Axis.

yLog()

Enables log scaling of y-Axis.

ydB()

Enables dB scaling of y-Axis.

zoom(x, y, factor)

Zoom at the given point by the given factor.

plotContent

Methods:

line(color, title)

Sets the line style and title. The last argument is optional.

mark(type, color, size)

Sets the marker type. The last 2 arguments are optional.

title(str)

Sets a string to show as title in the legend.

style

Methods:

brighter()

Makes the color brighter.

darker()

Makes the color darker.

dash(l1, l2, l3, l4, l5, l6)

Sets the dash style. The last 4 arguments are optional.

fill(color)

The color used to fill.

stroke(width)

Sets the stroke width.

image

Methods:

file(name)

Enables a file download.

outputSize(width, height)

Sets the svg-output size.

textSize(size)

Sets the text size.

data

Methods:

csv(name)

Creates a csv file.

dat(name)

Creates a gnuplot-dat file.

date()

Creates a string.

format(date-format, time-format)

Sets the date and time csv-format.

timeUnit(unit)

Sets the time name and unit.

static

Functions:

abs(value)

If value is negative, returns -value. Otherwise returns the value unchanged.

acos(float)

The mathematical acos function.

arrow(x1, y1, x2, y2, text, marker, color)

Creates an arrow plot content. The last 2 arguments are optional.

asin(float)

The mathematical asin function.

atan(float)

The mathematical atan function.

binAnd(a, b)

Returns the binary and of a, b.

binOr(a, b)

Returns the binary or of a, b.

bisection(func(float) float, min, max, eps)

Searches a zero in the given function by using the bisection method. The last argument is optional.

blockDelay(dt)

Creates a delay block.

blockGain(gain)

Creates a gain block.

blockLimiter(min, max)

Creates a limiter block.

blockPid(k_p, T_I, T_D)

Creates a PID block. The last argument is optional.

cmplx(re, im)

Creates a complex value.

color(r or n, g, b)

Returns the color with the number n or, if three arguments are specified, the given rgb color. The last 2 arguments are optional.

cos(float)

The mathematical cos function.

createLowPass(name, func(p) float, func(p) float, tau)

Returns a low pass filter creating signal [name].

dataSet(data...)

Creates a dat file.

exp(float)

The mathematical exp function.

float(value)

Returns the float representation of the value.

floor(float)

The mathematical floor function.

goto(n)

Returns a map with the key 'state' set to the given value.

graph(func(float) float, steps)

Creates a graph of the function to be used in the plot command. The last argument is optional.

hint(x, y, text, color)

Creates a new hint plot content. The last argument is optional.

hintDir(x1, y1, x2, y2, text, color)

Creates a new directional hint plot content. The last argument is optional.

int(value)

Returns the int representation of the value.

isFloat(value)

Returns true if the value is a float.

isInt(value)

Returns true if the value is a int.

linear(arg)

Creates a linear system. Can be used to cast a float, int or polynomial to a linear system.

link(name, link)

Used to create a link.

list(n)

Returns a list with n integer values, starting with 0.

ln(float)

The mathematical ln function.

log10(float)

The mathematical log function.

max(a, b)

Returns the larger of a and b.

min(a, b)

Returns the smaller of a and b.

nelderMead(func, initial, delta, iterations)

Calculates a Nelder&Mead optimization. The last 2 arguments are optional.

pid(k_p, T_I, T_D, T_P)

Creates a PID linear system. The fourth time T_P is the time constant that describes the parasitic PT1 term occurring in a real differentiation. The last 2 arguments are optional.

plot(content...)

Creates a plot.

poly(float...)

Declares a polynomial.

random(n)

Returns a random integer between 0 and n-1.

round(value)

Returns the value rounded to the nearest integer.

sign(value)

If value is negative, returns -value. Otherwise returns the value unchanged.

simulateBlocks(def, tMax)

Simulates the given model.

sin(float)

The mathematical sin function.

splitHorizontal(image1, image2)

Combines two images by a horizontal splitting.

splitVertical(image1, image2)

Combines two images by a vertical splitting.

sprintf(format, args)

The classic, well known sprintf function.

sqr(value)

Returns the square of the value.

sqrt(float)

The mathematical sqrt function.

string(value)

Returns the string representation of the value.

style(style, value)

Formats the value with the given style.

styleCell(style, value)

Formats the value with the given style. If used in a table, the style is applied to the cell instead of the containing value.

tan(float)

The mathematical tan function.

text(x, y, text, color)

Adds an arbitrary text to the plot. The last argument is optional.

throw(message)

Throws an exception.

tpA(m11, m12, m21, m21)

Creates a new two-port of type A.

tpC(m11, m12, m21, m21)

Creates a new two-port of type C.

tpCascade(tp1, tp2)

Cascade the given two-ports.

tpH(m11, m12, m21, m21)

Creates a new two-port of type H.

tpSeries(z)

Returns a series two-port.

tpShunt(z)

Returns a shunt two-port.

tpY(m11, m12, m21, m21)

Creates a new two-port of type Y.

tpZ(m11, m12, m21, m21)

Creates a new two-port of type Z.

trunc(float)

The mathematical trunc function.

xConst(y, color)

Creates a constant line plot content. The last argument is optional.

yConst(y, color)

Creates a constant line plot content. The last argument is optional.

zipFiles(name, list of files)

Used to create a zip file.