summation with for loop

조회 수: 1 (최근 30일)
clayton holmes
clayton holmes 2021년 12월 6일
편집: Abhijeet 2022년 6월 11일
How can i write code for this summation?

답변 (1개)

Abhijeet
Abhijeet 2022년 6월 11일
편집: Abhijeet 2022년 6월 11일
Hi Clayton Holmes,
Here are some assumptions i have made for writing the code :-
  • All the variables and the elements in matices used in the summation have been initialised to 1.
  • value of infinity is assigned with 10 ,which can be changed accordingly.
Below i have added the code for the given summation.
% initialising constant
inf =10;
x=1;
y=1;
z=1;
lambda=1;
t=1;
a=1;
B=ones([1,inf+1]);
N=ones([1,inf+1]);
U=ones([1,inf+1]);
C=ones([inf+1,inf+1,inf+1]);
sum=0;
for n=1:inf+1
for m=1:inf+1
for p=1:inf
sum=sum+cos(B(n)*z)*sin(N(m)*y)*sin(U(p)*y)*exp(-(lambda*lambda)*a*t)*C(n,m,p);
end
end
end
%value of sum
sum
sum = 170.2966

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by