dot product between two different size of matrix

조회 수: 22 (최근 30일)
Alan
Alan 2020년 12월 18일
댓글: James Tursa 2021년 12월 14일
Hello,
I have two matrix, one is A (1by 3 matrix), the other one is B (86 by 3 matrix). And I would like to calculate the dot product of dot(A,B). However, A and B are not the same size, so dot(A,B) function can not be performed successfullly.
How can I calculate the dot product between two different size of matrix without using for loop?
Many thanks!

채택된 답변

Ive J
Ive J 2020년 12월 18일
X = sum(bsxfun(@times, A, B), 2);

추가 답변 (1개)

James Tursa
James Tursa 2020년 12월 18일
Assuming everything is real and by "dot product" you aren't involving complex conjugates, simply this
C = B * A';
  댓글 수: 3
Prajwal Sridhar
Prajwal Sridhar 2021년 12월 9일
Is this same if i have matrix which is 50x2 and 2x2?
James Tursa
James Tursa 2021년 12월 14일
@Prajwal Sridhar Try it and see if it does what you want. If it doesn't, then open up a new Question and post a small example of inputs and desired output.

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

카테고리

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