How To Calculate Double Summation In Matlb

1 vue (au cours des 30 derniers jours)
Zahid Iqbal Rana
Zahid Iqbal Rana le 4 Déc 2014
Hey there,
I am trying to calculate C, as A=[1 2 3]; B=[1 2 3;4 5 6;7 8 9]; n=3
C=Sigma(i=1 to 3)Sigma(j=1 to3 )A(i)B (i,j)A(j)
Tell me Matlab code to calculate C. Thanks in advance

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 4 Déc 2014
A=[1 2 3];
B=[1 2 3;4 5 6;7 8 9];
s=bsxfun(@times,bsxfun(@times, B,A),A');
s=sum(s(:))
  2 commentaires
Zahid Iqbal Rana
Zahid Iqbal Rana le 4 Déc 2014
Thanks
Hassan Abdelazeem
Hassan Abdelazeem le 12 Mar 2022
clc
clear
A=[1 2 3];
B=[1 2 3;4 5 6;7 8 9];
for j=1:3
for i=1:3
c(i,j)=A(i)*B(i,j)*A(j);
end
end
c=sum(sum(c))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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