Multiplying Matrices, but with elements added together

조회 수: 10 (최근 30일)
Kevin Shen
Kevin Shen 2020년 10월 10일
댓글: Star Strider 2020년 10월 10일
Hello!
I have vector matrix A (3x1) and row matrix B (1x3). When multipying A*B, instead of having each element in the new 3x3 matrix be the elements multiplied together, is there a way to still make the 3x3 matrix but instead of each element of one matrix being multiplied by the elements of the other matrix, they would be added together.
If I don't make sence please tell me, I am new to MATLAB. Image of desired outcome below.
Thanks!
Kevin

채택된 답변

Star Strider
Star Strider 2020년 10월 10일
Yes, there is!
Try this:
A = [2; 3; 4];
B = [1 3 5];
C = bsxfun(@times, A, B) % Before R2016b
C = A * B % R2016b And Later
producing (for both):
C =
2 6 10
3 9 15
4 12 20
.
  댓글 수: 4
Kevin Shen
Kevin Shen 2020년 10월 10일
Thank you so much!
Star Strider
Star Strider 2020년 10월 10일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by