Subtract matrices in an array 'A' with elements from matrix 'B'
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 1x27 cell array 'A' containing 27 [56x2] doubles. I also have a 27x2 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?
댓글 수: 0
채택된 답변
추가 답변 (2개)
Walter Roberson
2021년 3월 11일
%generate A and B for demo
A = arrayfun(@(idx) rand(56,2), 1:27, 'uniform', 0)
B = rand(27,2)
%now for the work
C = cellfun(@(a,b) a-b, A, num2cell(B, 2).', 'uniform', 0)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!