| 1 |
//Code automatically generated with fuzzylite 6.0. |
| 2 |
|
| 3 |
FUNCTION_BLOCK cubic_approximator |
| 4 |
|
| 5 |
VAR_INPUT |
| 6 |
X: REAL; |
| 7 |
END_VAR |
| 8 |
|
| 9 |
VAR_OUTPUT |
| 10 |
ApproxXCubed: REAL; |
| 11 |
END_VAR |
| 12 |
|
| 13 |
FUZZIFY X |
| 14 |
RANGE := (-5.000 .. 5.000); |
| 15 |
TERM AboutNegFive := Triangle -6.000 -5.000 -4.000; |
| 16 |
TERM AboutNegFour := Triangle -5.000 -4.000 -3.000; |
| 17 |
TERM AboutNegThree := Triangle -4.000 -3.000 -2.000; |
| 18 |
TERM AboutNegTwo := Triangle -3.000 -2.000 -1.000; |
| 19 |
TERM AboutNegOne := Triangle -2.000 -1.000 0.000; |
| 20 |
TERM AboutZero := Triangle -1.000 0.000 1.000; |
| 21 |
TERM AboutOne := Triangle 0.000 1.000 2.000; |
| 22 |
TERM AboutTwo := Triangle 1.000 2.000 3.000; |
| 23 |
TERM AboutThree := Triangle 2.000 3.000 4.000; |
| 24 |
TERM AboutFour := Triangle 3.000 4.000 5.000; |
| 25 |
TERM AboutFive := Triangle 4.000 5.000 6.000; |
| 26 |
END_FUZZIFY |
| 27 |
|
| 28 |
DEFUZZIFY ApproxXCubed |
| 29 |
RANGE := (-5.000 .. 5.000); |
| 30 |
TERM TangentatNegFive := Linear 75.000 250.000; |
| 31 |
TERM TangentatNegFour := Linear 48.000 128.000; |
| 32 |
TERM TangentatNegThree := Linear 27.000 54.000; |
| 33 |
TERM TangentatNegTwo := Linear 12.000 16.000; |
| 34 |
TERM TangentatNegOne := Linear 3.000 2.000; |
| 35 |
TERM TangentatZero := Linear 0.000 0.000; |
| 36 |
TERM TangentatOne := Linear 3.000 -2.000; |
| 37 |
TERM TangentatTwo := Linear 12.000 -16.000; |
| 38 |
TERM TangentatThree := Linear 27.000 -54.000; |
| 39 |
TERM TangentatFour := Linear 48.000 -128.000; |
| 40 |
TERM TangentatFive := Linear 75.000 -250.000; |
| 41 |
METHOD : COGS; |
| 42 |
DEFAULT := nan; |
| 43 |
END_DEFUZZIFY |
| 44 |
|
| 45 |
RULEBLOCK |
| 46 |
RULE 1 : if X is AboutNegFive then ApproxXCubed is TangentatNegFive |
| 47 |
RULE 2 : if X is AboutNegFour then ApproxXCubed is TangentatNegFour |
| 48 |
RULE 3 : if X is AboutNegThree then ApproxXCubed is TangentatNegThree |
| 49 |
RULE 4 : if X is AboutNegTwo then ApproxXCubed is TangentatNegTwo |
| 50 |
RULE 5 : if X is AboutNegOne then ApproxXCubed is TangentatNegOne |
| 51 |
RULE 6 : if X is AboutZero then ApproxXCubed is TangentatZero |
| 52 |
RULE 7 : if X is AboutOne then ApproxXCubed is TangentatOne |
| 53 |
RULE 8 : if X is AboutTwo then ApproxXCubed is TangentatTwo |
| 54 |
RULE 9 : if X is AboutThree then ApproxXCubed is TangentatThree |
| 55 |
RULE 10 : if X is AboutFour then ApproxXCubed is TangentatFour |
| 56 |
RULE 11 : if X is AboutFive then ApproxXCubed is TangentatFive |
| 57 |
END_RULEBLOCK |
| 58 |
|
| 59 |
END_FUNCTION_BLOCK |