How do i extract data from 3D matrix?

조회 수: 8 (최근 30일)
Prakash Raut
Prakash Raut 2021년 11월 22일
답변: Voss 2021년 11월 23일
I have a matrix of size 256*256*256, i want to create a 2D matrix whose each row has information from the z direction of the original matrix, how do i do it?
  댓글 수: 2
James Tursa
James Tursa 2021년 11월 22일
편집: James Tursa 2021년 11월 22일
Please give us a small example of what you want. E.g., start with a 2x2x2 array and then show us the resulting 2x2 matrix you want as an output. Maybe all you need is sum(matrix,3) or mean(matrix,3), but we can't tell from what you have written so far.
Prakash Raut
Prakash Raut 2021년 11월 23일
편집: Prakash Raut 2021년 11월 23일
Hi James,
Here is an example of what i want (only my A is 256*256*256)
>> A
A(:,:,1) =
1 2
3 4
5 6
A(:,:,2) =
7 8
9 10
11 12
A(:,:,3) =
13 14
15 16
17 18
>> iwant
iwant =
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18

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

채택된 답변

Voss
Voss 2021년 11월 23일
[m,n,~] = size(A);
newA = reshape(permute(A,[2 1 3]),m*n,[]).';

추가 답변 (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