MATLAB: How to replace every other element in an array with a different number

arrayMATLABvector

I have a vector that I am trying to turn every other entry in the array to be negative.
So it would look like x = [200 -198 196 -194 … -2 0]
This is what I have. Is there a different approach I should be taking?
x = [200:-2:0]
x(2:2:end) = ()

Best Answer

>> V = 200:-2:0;
>> V(2:2:end) = -V(2:2:end)