In Matlab, it's easy to define a vector this way:
x = a:b:c
, where a
,b
,c
are real numbers, a < c
and b <= c - a
.
My problem is that I'm having troubles trying to define a formula to calculate the number of elements in x
.
I know that the problem is solved using the size command, but I need a formula because I'm doing a version of a Matlab program (which uses vectors this way), in another language.
Thanks in advance for any help you can provide.
Best regards,
Víctor
On a mathematical level you could argue that all of these expressions return the same:
Now you end up with integers from 0 to that term, which is:
There is one problem: Floating point precision. The colon operator does repeated summing, don't know any possibility to predict reproduce that.