Linked Questions

14 votes
2 answers

`Part` like `Delete`: How to delete list of columns or arbitrarily deeper levels [duplicate]

On trying to write this answer I reached the frustrating realization that I didn't have an efficient way to delete a list of columns or deeper level components in a simple way as ...
rhermans's user avatar
  • 35.9k
5 votes
2 answers

How do I use drop to drop the second element from all these sublists? [duplicate]

{{1, 2}, {2, 3}, {5, 4}} I tried to do this: Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}} but it gave {1} but what I want is {{1},{2},{5}}
user62264's user avatar
4 votes
2 answers

How do I delete items at the same position from every sub-list within a list? [duplicate]

We have data in a list called megadata where megadata[[1]] for instance are the temperatures of each data point, ...
user18537's user avatar
2 votes
2 answers

How to edit a list according to the other list? [duplicate]

Gday guys. This problem troubles me, and I hope you can help me solve it. Say I have two random lists L1={{2},{5},{1},{0},{4},{7},{8}} L2={2,5,1,0,4,7,8} and ...
user11726's user avatar
  • 105
198 votes
9 answers

Elegant operations on matrix rows and columns

Question The Mathematica tutorial has a section 'Basic Matrix Operations', describing operations like transpose, inverse and determinant. These operations all work on entire matrices. I am missing a ...
sjdh's user avatar
  • 7,557
18 votes
7 answers

Given a large binary matrix, find the largest submatrix containing non-zero elements

I'm looking for a way to reduce a binary matrix containing zeros at some positions into a matrix that contains no zeros by deleting rows and columns of the original matrix until only non-zero values ...
tavr's user avatar
  • 181
14 votes
3 answers

Correct way to remove matrix columns?

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 ...
sebastian c.'s user avatar
  • 1,953
15 votes
3 answers

Benchmarking expressions

It often happens that I'd like to know which of two or more alternative expressions (that should evaluate to the same value) is fastest. For example, below are three ways to define a function: ...
kjo's user avatar
  • 11.7k
5 votes
3 answers

List manipulation: Dropping first or last row or column of a matrix

How do I drop the first/last row or first/last column from a matrix? The general case is answered here but I am new to Mathematica and it the arbitrary case is unnecessarily complex. Suppose I am ...
Hirek's user avatar
  • 483
6 votes
3 answers

Looking for a better way to delete an arbitrary list of rows from a matrix

Delete is not suitable to delete the rows of a matrix, as illustrated below: ...
kjo's user avatar
  • 11.7k
11 votes
1 answer

Drop selection of columns from a ragged array

I have an application where I need to drop some arbitrary list of columns from a ragged array (where of course the shortest array rows have at least all the specified columns). E.g., given a ragged ...
ciao's user avatar
  • 25.5k
3 votes
3 answers

Matrix manipulation

Thank you for looking and answering this question. I am trying to create a new matrix from an old one. Meaning, I have a original matrix that's 20x20. I want to keep the first five lines of the matrix,...
user2558894's user avatar
3 votes
2 answers

Adding extra column to an existing table [duplicate]

Suppose I have following table- 1 5 8 2 6 9 3 7 10 0 0 0 Now, I want to add another column by exporting a data file. Suppose contents of that ...
solphy101's user avatar
  • 337
3 votes
3 answers

Inverse of ArrayPad operation, or removal of first column and first row of matrix [duplicate]

I have some large matrices, which I need to remove the first row and first column (both of which are full of zeroes). In this sense I need the inverse of "ArrayPad". For example, consider the matrix: ...
Nigel1's user avatar
  • 731
2 votes
1 answer

Multiple swapping of rows and columns

m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}}; I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns ...
santosh's user avatar
  • 603