Derived Variables are variables that are created from other variables using an expression. For example, you might create a numeric derived variable to show the sum of the values stored in two or more other numeric variables that you have collected from a device. Incredible, huh?
Sometimes users are not sure about the math functions allowed from the Derived Variables in Ubidots. Don't worry more about it! This guide is here to show you all the math functions available with Ubidots Derived Variables:
- ceil(x): Returns the ceiling of x as a float, the smallest integer value greater than or equal to x.
- floor(x): Returns the floor of x as a float, the largest integer value less than or equal to x.
- tan(x): Returns the tangent of x radians.
- cos(x): Returns the cosine of x radians.
- sin(x): Returns the sine of x radians.
- log(x[, base]): Returns the natural logarithm of x (by default base = e).
- sqrt(x): Returns the square root of x.
- abs(x): Returns the absolute value of x.
- round(x [, ndigits]): Returns the floating point value number rounded to "n" digits after the decimal point.
- previous(x): returns the value previous to the last value.
- diff_acu(x): returns the difference between current value and the last value (x_new - x_prev).
Ubidots stores your values as time-series variables, keeping this in mind we would define a variable values as a one dimension array:
diff_acu(x) function uses the last two values of your time-series variable, and can be defined as a piecewise function:
where xi is the actual value and xi-1 is the previous value, if the substract result between the actual and the previous value is greater than zero, it will return the substract, else it will return the actual.
Also, the math operations allowed are:
- Addition: +
- Subtraction: -
- Division: /
- Multiplication: *
- Exponentiation: **
- Module: %
Now you're ready to start with the Derived Variables, if you get ant issue using the variables please report to the Ubidots Community for assistance from not only Ubidots but also your fellow users.