필터 지우기
필터 지우기

How do I extract 3D matrix from 5D matrix

조회 수: 11 (최근 30일)
Yapo OBOUE
Yapo OBOUE 2019년 6월 12일
댓글: Yapo OBOUE 2019년 6월 12일
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 ?

채택된 답변

John D'Errico
John D'Errico 2019년 6월 12일
편집: John D'Errico 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.
  댓글 수: 1
Yapo OBOUE
Yapo OBOUE 2019년 6월 12일
Thanks very much dear John D'Errico. It works very as I wanted. Thank a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by