What you get with: val = [0.5./n:1./n:(n - 0.5)./n]

What this results in. Thanks in advance

1 Comment

Is n given? Is it positive? Is it at least 1 ? Is it at least 1/2 ?

Sign in to comment.

Answers (1)

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

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.
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

Sign in to comment.

Categories

Find more on Signal Processing Toolbox in Help Center and File Exchange

Tags

Asked:

on 10 Oct 2013

Commented:

on 10 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!