how to implement an infinite series?

조회 수: 6 (최근 30일)
Fatma Abdullah
Fatma Abdullah 2017년 6월 26일
댓글: Fatma Abdullah 2017년 7월 12일
im trying to implement the function in the attached image but i get that error "
Attempt to reference field of non-structure array.
at the step where (v) is being calculated. i dont know what it means and i dont know how to fix it
if true
clc;
close all;
N=32;
K=14;
c=0.8;
p=1;
pc=p*gamma(1+2/c);
T=399.01923099362968691492508329876;
s=T/(pc*(1+lambda);
syms i j f
nlambda = 50;
lambdavals2 = linspace(0,30,nlambda);
lambdavals = 10.^(lambdavals2/10);
for L = 1 : nlambda
lambda = lambdavals(L);
for i=K:N/2
w=nchoosek(N/2,i) %first series over i
z=arrayfun(@(j)nchoosek(K+i-1,j)*(-1)^(j),0 :K+i-1, 'uniform',0)%second series over j
v=symsum((-1)^(f)*(N+j-K-i+1)^(f)*gamma((f+1)*c/2)/(factorial(f)*(p*(T/(pc*(1+lambda))))^((f+1)*c/2)),i ,0, Inf)%third series over f
pd1temp=w*z*v
end
pd1 = c * K * nchoosek(N/2,K) * pd1temp; %the whole function
end
end
  댓글 수: 27
Fatma Abdullah
Fatma Abdullah 2017년 7월 12일
편집: Fatma Abdullah 2017년 7월 12일
its T/[pc*(1+lambda)] and its the same in the image just a different way of writing ....i might have missed the parenthesis in the code
Fatma Abdullah
Fatma Abdullah 2017년 7월 12일
and the value of T is not always 399 it could be any value >0 to thousands .....its calculated according to other equations mentioned in the paper

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 6월 26일
You have
i=13;
which assigns a specific numeric value to i . Then, a few lines later, you have
syms pfa1 i T j f
which overwrites i with a symbolic value, equivalent to doing
i = sym('i');
So now i is symbolic with no value other than itself, and has completely lost track of the fact it had previously been assigned 13.
Then later in your code you assume that i is still 13.
  댓글 수: 7
Walter Roberson
Walter Roberson 2017년 6월 29일
You asked for an infinite sum; that can potentially take a long time and a lot of memory unless convergence can be established.
That is why I have been asking the questions about the constraints: because knowing the constraints can make it much easier to establish whether something converges or not.
Fatma Abdullah
Fatma Abdullah 2017년 7월 3일
N is always integer positive even number,so yes N is an integer that is a multiple of 2, k is required to be an integer positive between value>0 and N/2 and could be even or odd so the limits is ]0,N/2] , c is limited between value>0 and infinity including fractions and is required to be positive so the limits of c is ]0,inf[

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by