## How do I extract 3D matrix from 5D matrix

Yapo OBOUE

### Yapo OBOUE (view profile)

さんによって質問されました 2019 年 6 月 12 日

### Yapo OBOUE (view profile)

さんによって コメントされました 2019 年 6 月 12 日
John D'Errico

### John D'Errico (view profile)

さんの 回答が採用されました
Hi everyone !
I working on 5D matrix configured as follow : [nt, nx, ny, np, nz]=size(D), such nt= 301; nx=12; ny=12; np=12; nz=12. I need to extract two matrices from D.
• the first one A of size : [nt, nx, ny]=size(A);
• the second B of size ; [nt, np, nz] =size(B);
Is there any Matlab code to extract these 3D matrices from D ?

#### 0 件のコメント

サインイン to comment.

## 1 件の回答

2019 年 6 月 12 日

### John D'Errico (view profile)

2019 年 6 月 12 日
採用された回答

What does it mean to extract a specific matrix?
p = 1;
z = 1;
A = D(:,:,:,p,z);
is a matrix of the desired size, extracting the (p,z) submatrix from D. But you may mean something completely different.
For the latter, you need to learn how to use squeeze.
x = 1;
y = 1;
B = squeeze(D(:,x,y,:,:));
Time to read the manual for you, since you need to learn about indexing matrices, something basic.

Yapo OBOUE

### Yapo OBOUE (view profile)

2019 年 6 月 12 日
Thanks very much dear John D'Errico. It works very as I wanted. Thank a lot.

サインイン to comment.

Translated by