This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
expressions [Tue Jan 12 14:15:29 2021] Alexander |
expressions [Sat Jan 16 17:02:23 2021] Alexander |
||
---|---|---|---|
Line 32: | Line 32: | ||
==== Using Spaces and Line Breaks ==== | ==== Using Spaces and Line Breaks ==== | ||
You can freely insert space characters and line breaks in formula, but do not break function names, numbers, operators. You do not need to enter special characters to indicate line break. | You can freely insert space characters and line breaks in formula, but do not break function names, numbers, operators. You do not need to enter special characters to indicate line break. | ||
+ | |||
+ | ===== Local variables in expression ===== | ||
+ | |||
+ | You can set a local variables in expression. Use semicolon to separate variable assignments and the result expression: '' | ||
===== Functions ===== | ===== Functions ===== | ||
Line 62: | Line 66: | ||
===== Boolean Logic ===== | ===== Boolean Logic ===== | ||
- | MagicPlot can interpret boolean logic expressions. Zero is interpreted as '' | + | MagicPlot can interpret boolean logic expressions. Zero is interpreted as '' |
==== The conditional function ' | ==== The conditional function ' | ||
Line 76: | Line 80: | ||
==== Equality Checking ==== | ==== Equality Checking ==== | ||
- | You have to be careful if you need to check equality of two values. Due to inaccuracy of computer floating-point calculations the result of evaluation is always approximate. For example, result of '' | + | You have to be careful if you need to check equality of two values. Due to inaccuracy of computer floating-point calculations the result of evaluation is always approximate. For example, result of '' |
Generally, if you want to check equality of two values you need to use some equality threshold for relative difference. That is, you should compare the modulus of relative difference of two values '' | Generally, if you want to check equality of two values you need to use some equality threshold for relative difference. That is, you should compare the modulus of relative difference of two values '' | ||
Line 85: | Line 89: | ||
===== Operators ===== | ===== Operators ===== | ||
- | ^ Operator | + | ^ Operator |
- | | '' | + | | '' |
- | | '' | + | | '' |
- | | '' | + | | '' |
- | | '' | + | | ''/'' |
- | | '' | + | | '' |
- | | '' | + | | '' |
- | | ''&'' | + | | '' |
+ | | ''&'' | ||
==== Operations Priority ==== | ==== Operations Priority ==== | ||
- | Operators with **lower** precedence value are evaluated **earlier**. You can use brackets to change calculation sequence. | ||
- | Expression | + | ^ Operations |
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
- | The reason for exponentiation being right-associative is that a repeated left-associative exponentiation operation would be less useful. Multiple appearances could (and would) be rewritten | + | Operators |
- | ^ Operations | + | Expression is evaluated |
- | | '' | + | |
- | | ''< | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | | '' | + | |
- | |''< | + | |
- | |'' | + | |
== Examples == | == Examples == |