Only 1st layer of a 3D Matrix.

12 views (last 30 days)
I have this code and I am having issues trying to figure out how to just display the 1st layer with it's own variable.
Also another variable that displays the absolute central colum.
Thank you.
A = ones(5,5,3).*reshape(1:3,1,1,3)

Accepted Answer

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam on 4 Sep 2020
For layer 1:
A(:,:,1)
For layer i:
A(:,:,i)
For the central column:
A(3,3,:)
  5 Comments
Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam on 4 Sep 2020
This command:
A(3,3,:) = 1;
fills the central column with 1

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 4 Sep 2020
ItsOwnVariable = A(:,:,1);
AnotherVariable = squeeze(abs(A(:,round(end/2),:)); %absolute, central ?

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by