subtraction ele by ele
이전 댓글 표시
hi all,
consider any two matrix A and B of 3X3 . i want to subtract every element of A from each element of B one by one. kindly tell the command please.
댓글 수: 1
Stephen23
2015년 4월 6일
MATLAB allows you to do this all at once using vectorized code, rather than one-by-one. This is faster, neater, and much less buggy code!
>> A = rand(3);
>> B = rand(3);
>> A - B
ans =
-0.15016 -0.043791 0.13661
0.74818 0.14698 0.12512
-0.84361 -0.70274 0.041771
채택된 답변
추가 답변 (1개)
David Young
2015년 4월 5일
-
댓글 수: 1
Star Strider
2015년 4월 5일
@4 X 4 —
David Young’s answer isn’t blank but maximally laconic. It is the ‘minus’ sign that will work for equally-sized matrices.
카테고리
도움말 센터 및 File Exchange에서 Parallel Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!