필터 지우기
필터 지우기

Extracting a 2 dimensional array from a 3 dimensional matrix.

조회 수: 145 (최근 30일)
ANAGHA GOURI
ANAGHA GOURI 2018년 2월 26일
댓글: Werner Barros 2020년 7월 29일
I have a 3D matrix named SM of order 17x10x181. I need to extract a 2D matrix from SM of order 10x181. What should be the command?

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 26일
squeeze(SM(5,:,:))
For example. Without the squeeze it would be a 1 x 10 x 181 and the squeeze makes it 10 x 181
  댓글 수: 2
onur erdem korkmaz
onur erdem korkmaz 2018년 6월 20일
Thank you for your answer. I want to ask an additional question. How do I add two matrices (10x81 add to another 10x81 in 17x10x81) with no for loop. (10x81 + 10x81 = 10x162)
Walter Roberson
Walter Roberson 2018년 6월 20일
[squeeze(SM(I, :, :), squeeze(SM(J,:,:))]
or
reshape( permute(SM([I, J], :, :), [2 3 1]), size(SM,2), [] )
Here [I, J] could be replaced by a vector of values to end up with a 10 x (81*n) array.

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

추가 답변 (1개)

KL
KL 2018년 2월 26일
편집: KL 2018년 2월 26일
use squeeze,
a = squeeze(yourmatrix(1,:,:))
first row from all pages. I suggest reading the doc page of squeeze.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by