0

I have a 3D matrix A of size 20x500x68. I have two vectors carrying information regarding this matrix which are:
B (containing zeros and ones) of size 1x68 and
C (containing numbers from 1 to 3) of size 1x68
(in length both B and C correspond to the third dimension of A).

I would like to create a "sub matrix" of A only of that third dimension where B==1 and C==3.

Schematically:

[sub matrix of A] = A (B = 1, C = 3)

Is there any way to do this without a loop?

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58
C_Hut
  • 31
  • 8

1 Answers1

0
SMA = A(:,:,B==1 & C==3)
%This submatrix contains all rows and columns of that third dimension of A
%where B equals 1 and C equals 3
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58