From: Jan Simon on
Dear Selvaraaju!

> like if N= 5
> 1 -1 1 -1 1

Next method:
pool = [-1, 1];
v = pool(mod(1:N, 2) + 1)

Good luck, Jan
From: Matt Fig on
Might be faster than indexing (?).


mod(1:5,2)*2 - 1
From: Walter Roberson on
Jan Simon wrote:
> Dear Selvaraaju!
>
>> like if N= 5
>> 1 -1 1 -1 1
>
> Next method:
> pool = [-1, 1];
> v = pool(mod(1:N, 2) + 1)

v = mod(1:N,2) * 2 - 1;


or

v = ones(1,N);
v(mod(0:N-1,2)) = -1;


or

v = ones(1,N);
v(2:2:end) = -1;

From: James Tursa on
How 'bout this one?

round(cos(mod((0:N)*4*atan(exp(0)),sqrt(4)*acos(log(1/exp(1))))))
From: Jan Simon on
Dear James!

> How 'bout this one?
> round(cos(mod((0:N)*4*atan(exp(0)),sqrt(4)*acos(log(1/exp(1))))))

You could solve SQRT(4) symbolically.
And here:
(0:N) * 4 * atan(exp(0))
additional brackets reduce the computational time:
(0:N) * (4 * atan(exp(0)))

Jan