MATLAB: How to eliminate certain columns from a matrix

matrix manipulation

If I need to remove any column how do I do it?
For example:
s is a mxn matrix.I need to remove the odd columns i,e, the 1st,3rd.. columns.

Best Answer

Let A be matrix
A(:,1:2:end) = [] % remove odd columns
A(:,3) = [] % remove third column
idx = [1 2 5 7] ;
A(:,idx) = [] % remove columns specified in idx