row wise Inner product of two matrices without using loop

2 vues (au cours des 30 derniers jours)
sandeep pandey
sandeep pandey le 18 Fév 2019
Commenté : madhan ravi le 19 Fév 2019
I have two matrices A= 40 x 50 and B = 61 x 50. I want to get the row wise dot product for the entire combination of rows of two matrices. Using for loop it is something like this
for i=1:40
for j=1:61
inner_prod(i,j) = dot (A(i,:),B(j,:);
end
end
Is there any way to do this avoiding the for loop and less execution time ?

Réponses (2)

madhan ravi
madhan ravi le 19 Fév 2019
  2 commentaires
Stephen23
Stephen23 le 19 Fév 2019
Modifié(e) : Stephen23 le 19 Fév 2019
+1 maths saves the day!
A * B.'
madhan ravi
madhan ravi le 19 Fév 2019
@stephen cobeldick: Thank you!

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 18 Fév 2019
Well that code is not right. But anyway, don't worry about a for loop with 40*61 iterations. That will be so fast there is no possible way you will notice how long it takes.
  1 commentaire
sandeep pandey
sandeep pandey le 18 Fév 2019
actually i have a large number of such A and B matrices (approx 4000) and this dot product is just a part of a bigger function. hence i was hoping to remove the for loop

Connectez-vous pour commenter.

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by