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]. That is, R2 is returned if (E1+E2)/2 < Arg <= (E2+E3)/2.

Function pattern

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

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 value depends on specific values of the argument. As a result, the above function can be read like this:

Arg

Returns

E1

R1

E2

R2

...

...

En

Rn

Application

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

We will use a SWITCH function in which the parameter SW depends on the values of the material thickness d(). The dependence is expressed in this pattern:

Material Thickness d()

SW

1.5

3

3

6

4

6

4.5

6

5

8

5.5

8

7

10

9

12

12

15

Using a SWITCH function, we can represent the table above in this way:

switch(d(), 1.5, 3, 3, 6, 4, 6, 5, 8, 7, 10, 9, 12, 12, 15) — IMPORTANT: This is what we type in the expression of the parameter SW.

As a graph, the function looks like this:

And as a table:

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

10

8< d() <= 10.5

12

10.5< d()

15