2

I have a list with dimensions {1000, 1000, 1} and I would like it to have dimensions {1000, 1000}. But Flatten[list,1] makes it {1000000, 1} and I've also tried Flatten[list,-1] with no success. Can I use flatten to do this or will I need a different command?

anderstood
  • 14,301
  • 2
  • 29
  • 80
user13948
  • 225
  • 1
  • 5

1 Answers1

0

Given a list of similar shape to the one in the question:

$a = Array[a[##] &, {3, 3, 1}];
$a // MatrixForm

unflattened array

... we can tell Flatten to leave level one untouched but flatten levels two and three together:

Flatten[$a, {{1}, {2, 3}}] // MatrixForm

partially flattened array

This syntax is the subject of the question Flatten command: matrix as second argument.

WReach
  • 68,832
  • 4
  • 164
  • 269