Insert/Edit Node

Function step > Insert/Edit

The Insert/Edit Node window contains the following elements:

Node

Name of the function node.

Unit

Unit of the function node. The definition of a unit has no influence on the calibration of the parameter and is only visualized for support.

Expression

Expression or formula of the function node.

Data

List

Shows all imported data channels.

Insert Data into Formula

Inserts the selected data channel from the list into the expression.

Parameter

List

Shows all existing parameters.

Insert Parameter into Formula

Inserts the selected parameter from the list into the expression.

Create

Opens the Create Parameter window where you can create a new parameter.

Import

Opens an open file dialog where you can import a list of parameters.

Delete

Deletes the selected parameter.

Edit

Opens the Edit Parameter window for the selected parameter.

Nodes

List

Shows all existing function nodes and imported models. When an imported model is used in a function node, an additional node, named <model name>_mdl.<output name> by default, is available for each model output.

Insert Node into Formula

Inserts the selected node or model into the expression. In case of a model, the node name is set to <model_name>_mdl (see the Closedexample).

Calculation buttons

Inserts the *, /, +, or - operator into the expression.

This results in element-wise multiplication, division, addition, or subtraction.

Inserts the square root sqrt( operator into the expression. The expression must end with )..

Inserts the ^ operator into the expression.

x^y means row-by-row x to the power of y.

Inserts the absolute value abs( operator into the expression. The expression must end with ).

ExampleClosedabs(-3) ≥ 3

Inserts the bswitch( operator into the expression. The expression must end with ).

Binary switch, element-wise:

y = bswitch (x, a, b)

y = a for x <= 0

y = b for x > 0

ExampleClosedbswitch (%speed% > 2000, %Y_1%, %Y_2%)

Inserts an opening or closing bracket into the expression.

Inserts a comma into the expression.

Inserts the min(/max( operator into the expression. The expression must end with )..

min = minimum of two inputs

max = maximum of two inputs

ExampleClosedmin(%in1%, %in2%), max(%in1%, %in2%)

Inserts the & operator into the expression, which means a logical element-wise AND.

ExampleClosed%Speed% > 2000 & %Load% > 6 

Inserts the | operator into the expression, which means a logical element-wise OR.

ExampleClosed%Speed% > 2000 | %Load% > 6 

Inserts the ~ operator into the expression, which means a logical not.

Example ~(%x1% & %x2%) 

Inserts the cumsum( operator into the expression, which means the cumulative sum of a numerical sequence. The expression must end with ).

ExampleClosedcumsum(%y%): [1 2 4] ≥ [1 3 7] 

Inserts the </<=/==/>=/> operator into the expression, which means is less than/less than or equal to/equal to/greater than or equal to/greater than.

Inserts the warnif( operator into the expression. The expression must end with ).

It allows you to define checks that are automatically executed after each optimization run. If the defined condition is met, the specified warning text is displayed in the log window.

To use the warnif operator, you need to insert a condition in the expression field after clicking the button. The syntax for the warnif operator is as follows:

y = warnIf(condition, 'warningText').

ClosedExamples

warnIf(%MapDragTorque%(%Speed%, %Rel_Airmass%) > 0, 'Warning')

In this example, if at least one of the values of the map parameter MapDragTorque is greater than zero after the optimization, the text "Warning" will appear in the log window.

warnIf(%speed% < 0, 'speed less than zero')

In this case, if the value of speed is less than zero after the optimization run, the warning "speed less than zero" will be issued.

Inserts the timeDelay( operator into the expression. The expression must end with ).

It allows you to delay a signal by one time step. After clicking the button, you need to insert a condition in the expression field using the following syntax:

timeDelay(x, initialValue)

In this expression, initialValue is returned in the first step, and it is the only way to access nodes further in the function.

ClosedExamples

timeDelay(%transferFcn%, %setpoint%(1))

In this example, the signal from transferFcn is delayed by one time step, with the initial value set to the first element of the input setpoint.

y = timeDelay(%y%, 0.0)

Here, the value of y is delayed by one time step, with an initial value of 0.0.

Inserts the delta T (sample time, dT) operator into the expression.

It represents the sample time in the data and will be replaced with the corresponding value during execution.

ClosedExamples

dT ./ %filterConstant%

In this example, dT is the value from the time [s] column in the Data step, while %filterConstant% is a parameter used in the calculation.

y = timeDelay(%y%, 0.0) * dT

In this case, the value of y is multiplied by the sample time dT after applying a time delay.

Inserts the roundToDiscreteValues( operator into the expression, which rounds a node to a specific discrete value. The expression must end with ).

After inserting the operator, you need to select a discrete parameter and enter the desired values. The syntax is as follows:

roundToDiscreteValues(node, [value1, value2, ...])

ClosedExamples

roundToDiscreteValues(%calMap_SCV%(%speed%, %load%), [0, 1])

In this example, the output of the calibration map calMap_SCV is rounded to the discrete values 0 and 1 based on the inputs speed and load.

roundToDiscreteValues(%myTernary%, [0, 1, 2])

Here, the value of myTernary is rounded to the discrete values 0, 1, and 2.

Inserts the steadyState_abs( operator into the expression, which calculates the steady state of a signal based on the window length and window height. The expression must end with ). The syntax is as follows:

steadyState_abs(x, windowLength, windowHeight, sampleRate)

ClosedExample

steadyState_abs(%signal%, 10, 200, dT)

In this example, the steady state of the signal is calculated using a window length of 10, a window height of 200, and the sample rate represented by dT.

Deletes the last entry in the expression field (backspace).

The following operators are supported. Select them from the burger menu () or type them in manually:

log(x)

The natural logarithm (base e).

ExampleClosedlog(exp(2)) => 2

log10(x)

The common logarithm (base 10).

ExampleClosedlog10(10^2) => 2

exp(x)

Euler's number raised to the power of ex.

ExampleClosedexp(1)) => 2.718

sin(x), cos(x), tan(x), tanh(x), atan(x)

The trigonometric functions, the input is in radians.

ExampleClosedsin(3.1416) ~> 0

atan2(x, y)

The four-quadrant inverse tangent, input is given in radians.

ExampleClosedatan2(%id%, %iq%)

delayseq(data, n)

Delay a signal by n time steps. The start of the signal is filled with zeros.

ExampleCloseddelayseq([1; 2; 3; 4;], 2) => [0; 0; 1; 2]

bitget(x, bitPos)

The MATLAB® bitget function returns a bit value at a specified position (bitPos).

ClosedExample

bitget(4, 3) returns 1

bitget(4, 2) returns 0

In this example, the integer 4 is represented in binary as 100. The function bitget(4, 3) retrieves the bit at position 3, which is 1, while bitget(4, 2) retrieves the bit at position 2, which is 0.

Further notations are supported:

z = [x, y]

Creates a multidimensional vector. A vector can be extracted with y = z(:, 2). This can be useful, e.g., when a subfunction shall returns multiple nodes/vectors.

y = zeros(size(x))

Creates a vector of zeros.

y = ones(size(x))

Creates a vector of ones.

?

Opens the online help in the appropriate context.

Validate

Checks the validity of the expression.

OK

Applies your settings and closes the window.

Cancel

Discards your settings and closes the window.

See also

Add a Function Node

Editing a Function Node

Modeling the Function

Mathematical Operators for Function Nodes