2D subtraction from 3D

9 visualizzazioni (ultimi 30 giorni)
Haa Andrew
Haa Andrew il 21 Set 2017
Commentato: Andrei Bobrov il 21 Set 2017
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 Commenti
John Chilleri
John Chilleri il 21 Set 2017
C = zeros(50,60,180);
for i = 1:180
C(:,:,i) = A(:,:,i) - B;
end
Is this what you mean?
Andrei Bobrov
Andrei Bobrov il 21 Set 2017
?
size of the C -> [50x 50 x180]? Maybe - [50x 60 x180]

Accedi per commentare.

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 21 Set 2017
C = A - B;
or
C = bsxfun(@minus,A,B);
  2 Commenti
Walter Roberson
Walter Roberson il 21 Set 2017
The first of those works in R2016b or later but not in earlier versions.
Andrei Bobrov
Andrei Bobrov il 21 Set 2017
Walter! I am agree with you!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by