I start off with m = 1000 x 5 matrix, and I would like to remove first column to get 1000 x 4 matrix and repeat again for 1000 x 3 and so on. Is there an efficient way to do this? I see Insert to add columns or rows but don't see command for removing? I see maybe use the extract but is this only for a single vector extraction?

3 Answers
3

As has been shown there are a number of ways to do this. To summarize:

m = RandomInteger[9, {6, 4}]

All of these:

Drop[m, 0, 1]
Rest /@ m
m[[All, 2 ;;]]
{##2} & @@@ m

Produce:

Each has a place. For the specific operation Rest is especially clear. Drop can easily drop columns besides the first, e.g. Drop[m, 0, {3}], and it is very fast. Part is also usually very fast, and allows assignments which is both flexible and efficient (when applicable). SlotSequence is simply fun and can be quite useful when you also want to do something with the elements.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.