exp*prod*exp(x(lnx)^k) solving equation
Afficher commentaires plus anciens
I want to solve this equation in MATLAB:


term2 = for k=1:numel(j) (prod(D(k,:)==exp(P(1).*c.*(log(P(1)).^k/factorial(k))))) end
term1= exp(-(lambda*P(1).*pi.*(r.^2)))
I'm trying to do that:
function F = root2d(P);
lambda = 2*10^-4;
th = -40:-1:-106;
PL1 = 10471285.480509; % (mw)
p1 = 10;
p2 = 6 ;
p3 = 8 ;
al = 2.5;
T = 10.^(th./10);
r = (p1*PL1^(-1)./T).^(1/al);
R = (p2*PL1^(-1)./T).^(1/al);
syms P
c = (lambda.*pi.*(R.^2));
j = 1:3;
D = zeros(3,67);
for k = 1:numel(j)
F(1) = (prod(D(k,:)==exp(P(1).*c.*(log(P(1)).^k/factorial(k))))).*exp(-(lambda*P(1).*pi.*(r.^2)))-P;
end
%fun = @root2d; in the command line
%P0 = 0; in the command line
%P = fsolve(fun,P0) in the command line
when th = -40
Error using fsolve (line 269)
FSOLVE requires all values returned by functions to be of data type double
end.
but when th is a vector (1*67)double (th = -40:-1:-106)
Error in fsolve (line 230)
fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial objective function evaluation. FSOLVE cannot continue.
`
Do you have an idea?
2 commentaires
John D'Errico
le 16 Juin 2018
Modifié(e) : John D'Errico
le 16 Juin 2018
This is destined for failure as you are doing it.
1. You seem to be trying to solve a problem for each value of th, which is a vector. But you are starting with a scalar value for P0? Thus, for each value of th, you compute T. Then you compute r and R.
2. As importantly, exponentials are bad things when working in double precision. If you log that expression however, it turns into a sum that will be much better posed, possibly now solvable using double precision arithmetic.
3. You are using syms in conjunction with fsolve. fsolve is not a symbolic solver. Just because you don't know the value of P, does not make this a symbolic problem.
Marwen Tarhouni
le 16 Juin 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics and Optimization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

