MATLAB: Adding integer to specifc matrix columns using bsxfun

bsxfunintegermatrixmatrix indexing

I would like to add the integer 1 to every element in a matrix, except for the elements in the first column. I would like to use the function bsxfun since the matrix I wish to add 1 to is very large. What would be the correct syntax for this?

Best Answer

M(:,2:end) = M(:,2:end)+1
or
V = ones(1,size(M,2));
V(1) = 0;
M = bsxfun(@plus,M,V)