MATLAB: How to change column values from a matrix

columnforfor functionmatrixmatrix manipulation

Hi, I have to add [column number – 1]*0.5 to each column from a matrix,
For example:
0 0 0 0 0
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
to
0 0.5 1.0 1.5 2.0
1 1.5 2.0 2.5 3.0
2 2.5 3.0 3.5 4.0
3 3.5 4.0 4.5 5.0
I have to do that for an imported 700×20 matrix that already exists, maybe using for function, but I don't know how.

Best Answer

yourMatrix+(0:19)*0.5