MATLAB: How to multiply just certain elements of a column in a matrix by a factor

MATLABmatrix

Supposing if I have a matrix of 20×3 (20 rows and 3 columns). I want to multiply 5th to 10th element of 3rd column by a factor, say zero. How can I do that?

Best Answer

testMat=ones(20,3)
testMat(5:10,3)=testMat(5:10,3).*0