MATLAB: Subtract matrices in an array ‘A’ with elements from matrix ‘B’

for loopmatrix manipulation

I have a 1×27 cell array 'A' containing 27 [56×2] doubles. I also have a 27×2 matrix 'B'. I want to subtract all the elements from A{1} with B(1,:) and A{2} with B(2,:) and so on. How do I write a for loop for this?

Best Answer

Thank you for the answers. I managed to solve this using the following code.
[m n]=size(B);
for i=1:length(A)
for j=1:m
D{i}(j,:)= A{i}(j,:) - B(i,:);
end
end