Effacer les filtres
Effacer les filtres

How this write in summation form in matlab a0*b0+a1*b​1+........​..........​.an*bn?

1 vue (au cours des 30 derniers jours)
Abu Zar
Abu Zar le 10 Jan 2023
Modifié(e) : Dyuman Joshi le 10 Jan 2023
limit is from 0 to n
  3 commentaires
Dyuman Joshi
Dyuman Joshi le 10 Jan 2023
Thanks for the correction @John D'Errico, I overlooked it
the cyclist
the cyclist le 10 Jan 2023
Modifié(e) : the cyclist le 10 Jan 2023
The solution in @Dyuman Joshi's comment above assumes that a and b are row vectors. If they are column vectors, it will result in matrix output.
Better to use dot(), I would say. See my solution.

Connectez-vous pour commenter.

Réponse acceptée

the cyclist
the cyclist le 10 Jan 2023
Assuming you actually have vectors, and not variables named a0, a1, a2, etc., then you can use the dot function:
a = [1 2 3]';
b = [4 5 6];
dot(a,b)
ans = 32
Note that this will work on row vectors, column vectors, or even a mixture (which is how I defined them in this example).

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics 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