2D subtraction from 3D

조회 수: 10 (최근 30일)
Haa Andrew
Haa Andrew 2017년 9월 21일
댓글: Andrei Bobrov 2017년 9월 21일
I have 3D matrix A=50x60x180 and I want subtract B=50x60 to get same size C=50x50x180? Can anybody use for loop to do this operation?
  댓글 수: 2
John Chilleri
John Chilleri 2017년 9월 21일
C = zeros(50,60,180);
for i = 1:180
C(:,:,i) = A(:,:,i) - B;
end
Is this what you mean?
Andrei Bobrov
Andrei Bobrov 2017년 9월 21일
?
size of the C -> [50x 50 x180]? Maybe - [50x 60 x180]

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2017년 9월 21일
C = A - B;
or
C = bsxfun(@minus,A,B);
  댓글 수: 2
Walter Roberson
Walter Roberson 2017년 9월 21일
The first of those works in R2016b or later but not in earlier versions.
Andrei Bobrov
Andrei Bobrov 2017년 9월 21일
Walter! I am agree with you!

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

추가 답변 (0개)

카테고리

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