There's a summation equation that I need to implement for various values of a variable x. Please help.

조회 수: 1 (최근 30일)
The equation in question is:
P_bl= (A^Kcell/ Kcell ! ) * ( Summation (k=0 to Kcell) of A^k/ k !)^ -1
I have to prepare a MATLAB code for obtaining values of P_bl for varying values of A and Kcell. i. A=70 and Kcell=70:100 ii. Kcell= 75 and A= 40:160
Please help.
  댓글 수: 3
Mayank Kashyap
Mayank Kashyap 2017년 2월 7일
편집: Mayank Kashyap 2017년 2월 7일
Well, my bad I guess. New to MATLAB and this community. Please bear with me and help me out.
I've attached the file here and will paste the code after this too:
x=70:100;
%x is Kcell here
A=70;
syms k x
S=(symsum(A.^k/factorial(k),k,0,x))^-1;
for i=1:length(x)
P_bl(i)= ((A^x)/factorial(x))*S;
end
plot(P_bl,x)

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

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 7일
You have the significant problem that A^k is not defined for vector A. A^k is defined for scalars and for square matrices.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 2월 7일
length(x) is 1 because of "syms x" .
syms x
means the same thing as
x = sym('x')
that is, x is overwritten with the symbolic name x. This destroys any previous meaning it had.
Perhaps in your symsum you mean that you wanted to process it for all the various values that are in the x vector you used. If so, then
syms k N
S=(symsum(A.^k/factorial(k),k,0,N))^-1;
subs(S, N, x)
Now look at
P_bl(i)= ((A^x)/factorial(x))*S
This does not involve "i" at all. Also, the symsum version is building a total but the loop version is not building a total.

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

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by