MATLAB: I have a matrix a=[1,2,3,4​……….​,20], Now I want to multiply every other element in a with -1 to get a=[1,-2,3,​-4……..​……..-2​0].

every othermatrix manipulationmultiply

I have a matrix a=[1,2,3,4……….,20] Now I want to multiply every other element in 'a' with -1 to get a=[1,-2,3,-4…………….-20]. please help me with this……!!

Best Answer

a(2:2:end)=-a(2:2:end);
Related Question