필터 지우기
필터 지우기

Hello all! I have some ambiguity with MATLAB. I saved my matrix as A(:,:,1) in workspace. Now I want to access column or some entries of my big matrix on command window.

조회 수: 1 (최근 30일)
I have the following loop.
for i=1:4
A(:,:,i)=i*ones(4,4);
end
Now I want second rows of A(:,:,i) i.e second row of A(:,:,1), second row of A(:,:,2), second row of A(:,:,3) and second row of A(:,:,4).

채택된 답변

Wan Ji
Wan Ji 2021년 8월 23일
Do by following code
for i=1:4
A(:,:,i)=i*ones(4,4);
end
B = permute(A,[3,2,1]);
B(:,:,2)
The result is
ans =
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
  댓글 수: 3
dpb
dpb 2021년 8월 23일
"I just want to have 2nd row of A(:,:,2) only on my comand window" @Teshome Kumsa
Well, that's just
B=A(2,:,2);
Wan Ji
Wan Ji 2021년 8월 23일
Hi, Teshome Kumsa,
Follow pdb's answer. And transpose it.
B=squeeze(A(2,:,:))'; % B is what you want
Also without using squeeze, you can achieve it by
B = reshape(A(2,:,:), size(A,2), size(A,3))';

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

추가 답변 (1개)

dpb
dpb 2021년 8월 23일
B=squeeze(A(2,:,:));

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by