SWITCH functions

The SWITCH function takes an argument expression (Arg) and checks in which predefined value intervals [(E1 + E2)/2; (E2 + E3)/2, ... ; (En-1 + En)/2] it falls. It then returns the respective predefined result value [R1; R2, ... ; Rn].

Function pattern

switch (Arg, E1, R1, E2, R2, E3, R3, En, Rn)

As a graph:

Function Pattern as a Graph

As a table:

When Arg Is The Function Returns
Arg ≤ (E1 + E2)/2 R1
(E1 + E2)/2 < Arg < (E2 + E3)/2 R2
(E2 + E3)/2 < Arg < (E3 + E4)/2 R3
... ...
(En-1 + En)/2 < Arg Rn

SWITCH functions are appropriate when the return values depend on specific values of the argument. As a result, the above function can be read like this:

When Arg Is The Function Returns
E1 R1
E2 R2
... ...
En Rn

Application

Let's consider how we can use a SWITCH function for the parameter SW whose value depends on the material thickness d().

The SW Parameter Depends on the Material Thickness

The dependence is expressed in the following pattern:

Material Thickness SW
1.5 3
3 6
4 6
4.5 6
5 8
5.5 8
7 10
9 12
12 15

A SWITCH function describes the above table like this:

switch(d(), 1.5, 3, 3, 6, 4, 6, 5, 8, 7, 10, 9, 12, 12, 15)

IMPORTANT: This is also what we type in the expression of the parameter SW.

Rendered in a graph, the function looks like this:

The SWITCH Function as a Graph

As a table, it looks like this:

WHEN SW Is
d() ≤ 2.25 3
2.25 < d() ≤ 2.5 6
2.5 < d() ≤ 4.5 6
4.5 < d() ≤ 6 8
6 < d() ≤ 8 1
8 < d() ≤ 10.5 12
10.5 < d() 15