2D subtraction from 3D

9 次查看(过去 30 天)
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