MATLAB: Divide every entry of a column by the same number

MATLABmatrix

Suppose I have
A = [1 2 3; 4 5 6; 7 8 9];
and I want to divide every entry in the second column by 2 so the answer is
B = [1 1 3; 4 2.5 6; 7 4 9];
What will be a compact way of doing this?

Best Answer

A(:,2)=A(:,2)./2;
B=A
Related Question