What you get with: val = [0.5./n:1./n:(n - 0.5)./n]
Show older comments
What this results in. Thanks in advance
1 Comment
Walter Roberson
on 10 Oct 2013
Is n given? Is it positive? Is it at least 1 ? Is it at least 1/2 ?
Answers (1)
Roger Stafford
on 10 Oct 2013
Provided n is a positive integer, you get the following row vector with n elements:
[1/(2*n),3/(2*n),5/(2*n), ... ,(2*n-1)/(2*n)]
2 Comments
Daniel Shub
on 10 Oct 2013
I am not sure this is entirely accurate with regards to the actual implementation. See my question on how COLON works. The COLON function is pretty smart when it comes to minimizing floating point error accumulation.
Jos (10584)
on 10 Oct 2013
Indeed:
n = 5 ;
x = [0.5./n:1./n:(n - 0.5)./n]
y = [0.5:1:(n-0.5)]./n
% looks the same, but
isequal(x,y), x-y
Categories
Find more on Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!