1
$\begingroup$

I have a 3d matrix of dimension $11 \times 1000 \times 3$. I need to remove the first 10 rows from all 2D matrix so that the output is $11 \times 990 \times 3$. After that I need to convert it into a 2d matrix such that the dimension becomes $10890\times3$.

$\endgroup$
1
  • $\begingroup$ Look at Part for selecting pieces of the matrix and ArrayReshape for reshaping. $\endgroup$
    – bill s
    Commented Jul 7, 2021 at 10:39

1 Answer 1

5
$\begingroup$

As suggested in the comment, you should use Part and ArrayReshape:

(* Create random 3D matrix with dimensions 11 x 1000 x 3 *)
mat = RandomReal[1, {11, 1000, 3}];
Dimensions[mat]
(* {11, 1000, 3} *)

mat2 = mat[[All, 11 ;;, All]];
Dimensions[mat2]
(* {11, 990, 3} *)

mat3 = ArrayFlatten[mat2, 1];
Dimensions[mat3]
(* {10890, 3} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.