I am going to share the comparison results of colon operators in octave and
matlab.
* octave (3.8.2 on cygwin) vs matlab (R2012b on XP windows)
* test numbers: (-2:0.1:1)
* test methods: colon operator t1=(-2:0.1:1) vs t2=linspace(-2,1,31)
* output format: compare them with hexadecimal of raw IEEE bits.
[ num2str(t2','%5.2g'), repmat(' ',[numel(t1) 1]), num2hex(t1'), repmat('
',[numel(t1) 1]), num2hex(t2') ]
* result of octave: [index, colon oper, linspace ]
* result of matlab:
* conclusion:
In matlab, the result of colon operator is very close to the result of the
linspace.
Note that all multiples of 0.5 have the exact floating point number. (which
has compact significant digits)
However, the result of colon operator in octave shows the poorest
performance: the values of -0.5, 0 and 0.5 do not show the exact floating
point representations.
The colon operation with floating-point numbers needs to improve, anyhow.
Or, the linspace function is preferable in Octave.