How To Calculate Double Summation In Matlb

조회 수: 3 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by