system of equations (solve exponentiel equations

Hi,
I want to solve this system of equations
P= exp(-r.^2.*P+R.^2.*Q).*sum((r.^2.*P +R.^2.*Q).^m./factorial(m)) // with m=(0:1:k-1); ;k=5
Q=exp(-r.^2.*P + R.^2.*Q.*sum((r.^2*P + R.^2.*Q).^n./factorial(n)) // n=(k:1:K_avg); K_avg=10
I tried to solve this system with solve. the result of execution : error eqns.
do you have an idea ?
th = -80:-3:-106;
list1 = zeros(size(th));
list2 = zeros(size(th));
r=[ 15.8 20.8 27.5 36.3 47.6 63.9 83.1 109.6 115.2];
R=[ 8.12 10.9 14.4 19.2 25.6 33.1 43.5 75.6 80.2];
for i = 1:numel(th)
K_avg=17;
k=9;
m=(0:1:k-1);
n=(k:1:K_avg);
syms P Q
eqns= [exp(-r.^2.*P+R.^2.*Q).*sum((r.^2.*P +R.^2.*Q).^m./factorial(m))-P==0,exp(-r.^2.*P + R.^2.*Q.*sum((r.^2*P + R.^2.*Q).^n./factorial(n))-Q==0)];
vars = [P Q];
[sol1,sol2]=solve(eqns,vars);
list1(i) = sol1;
list2(i) = sol2;
end

 채택된 답변

madhan ravi
madhan ravi 2018년 9월 10일

1 개 추천

@Marwen you get error/s because the number of elements m,n and R,r are not the same in order to make the loop perform calculations all the arrays should have the same number of elements.

댓글 수: 9

@madhan ravi, i modified the number of elements of {m,n,R,r}, I get the same error with the number of elements is the same.
madhan ravi
madhan ravi 2018년 9월 10일
편집: madhan ravi 2018년 9월 10일
upload your modified code
madhan ravi
madhan ravi 2018년 9월 10일
편집: madhan ravi 2018년 9월 10일
syms P Q
%neglected to loop to check if theres any possible solution to be attained but the solution is an empty sym which means no solution.
th = -80;
r=[ 15.8];
R=[ 8.12];
m=0;
n=(k);
eqn1= exp(-r.*r.*P+R.*R.*Q.*sum((r.*r.*P +R.*R.*Q).*(m.*m)./factorial(m))-P);
eqn2=exp(-r.^2.*P + R.^2.*Q.*sum((r.^2*P + R.^2.*Q).^n./factorial(n))-Q);
K_avg=10;
k=5;
[sol1,sol2]=solve(eqn1,eqn2,[P Q])
Matlab is not able to solve it.
@ madhan ravi, thank you for your explanation , but when i add lambda*pi in the equation
lambda= 1.0000e-04;
eqn1=exp(lambda*pi*r.^2.*P+lambda*pi*R.^2.*Q).*sum((lambda*pi*r.^2.*P +lambda*pi*R.^2.*Q).^m./factorial(m))-P;
eqn2=exp(-lambda*pi*r.^2.*P + lambda*pi*R.^2.*Q).*sum((lambda*pi*r.^2*P + lambda*pi*R.^2.*Q).^n./factorial(n))-Q;
vars = [P Q];
[sol1. sol2]=solve(eqn1,eqn2,vars);
result:Warning: Cannot solve symbolically. Returning a numeric approximation instead.
madhan ravi
madhan ravi 2018년 9월 11일
편집: madhan ravi 2018년 9월 11일
Sol=vpasolve(eqn1,eqn2)
@ madhan ravi :result of execution
Sol =
P: [1x1 sym]
Q: [1x1 sym]
what does this solution mean :empty solution?
Sol.P
Sol.Q
give a vote if you get the answer :)
@madhan ravi, thank you :problem solved
@Marwen your welcome.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2018년 9월 10일

댓글:

2018년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by