MATLAB: How to acess elements of a matrix with round indexes without loops

indexindexingMATLAB

For exemple if I have a matrix that is 3×3
1 1 1
A = 1 1 1
1 1 1
I want to multiply elements with round indexes by 2 so it look like this:
1 2 1
A = 2 1 2
1 2 1

Best Answer

A(2:2:end)=A(2:2:end)*2