MATLAB Answers

How can I extract the slices of a 3D matrix in x-direction from a 3D matrix?

165 views (last 30 days)
Javad
Javad on 6 Jul 2018
Commented: Javad on 12 Jul 2018
I have a 3D matrix, which is a model of the porous media of a rock. I want to extract three 3D matrices from it so that each contains the 2D slices in a specific direction, for example x. To be clear, the matrix x contains the 2D slices in x direction, y in y-direction and z in the z-direction. I appreciate any hint or help to solve my issue.
Regards
  2 Comments
Javad
Javad on 7 Jul 2018
Dear James First, thanks for your answer. But I think my question was not clear. To be clear I explain more. I have 3D matrix, which is in fact a digital rock model. All the arrays of the matrix are 0 or 1. I want to draw the streamlines in it using the command 'streamline'. But this command need x, y, z. I want to extract these three matrices from my 3D matrix. Can you help me in this regard? Thanks

Sign in to comment.

Accepted Answer

Anton Semechko
Anton Semechko on 6 Jul 2018
Suppose you have G, which is a Y-by-X-by-Z 3D array, then
i-th xy slice:
G_yx=G(:,:,i); % Y-by-X array
i-th xz slice:
G_xz=permute(G(i,:,:),[2 3 1]); % X-by-Z array
i-th yz slice:
G_yz=permute(G(:,i,:),[1 3 2]); % Y-by-Z array
  5 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!