May I know if there is a function which can create an array of elements which are equally spaced? Just like MATLAB function "linspace" which creates number of equally spaced elements between two values.
For example, I would like to know if arduino can create an array with 11 equally spaced elements between 0 and 4 which gives us [0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 2.8, 3.2, 3.6, 4.0]. Please help me.
And remember that an int divided by an int will yield an int (any fractional part will be silently discarded). But dividing a float by an int, or a float by another float, will work fine.
float x;
x = 9 / 2;
// x is now 4.0
x = 9.0 / 2;
// x is now 4.5
For so few values, just initialise the array when it’s defined.
OR, as the members are linearly spaced, simply calculate them when needed.
The difference in speed of these options will make very little difference to your code, and will be faster than a special function to return your value.