How To Calculate Double Summation In Matlb

2 ビュー (過去 30 日間)
Zahid Iqbal Rana
Zahid Iqbal Rana 2014 年 12 月 4 日
コメント済み: Hassan Abdelazeem 2022 年 3 月 12 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 4 日
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 件のコメント
Zahid Iqbal Rana
Zahid Iqbal Rana 2014 年 12 月 4 日
Thanks
Hassan Abdelazeem
Hassan Abdelazeem 2022 年 3 月 12 日
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))

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by