Hello all,
I have the following equation that needs to be solved by MATLAB but it gives me empty sym. I don't know why
syms T a b
eqn= (a*b*exp(b/T)*((1 - exp(a*b*ei(b/T) - T*a*exp(b/T))*exp(294*a*exp(b/294) - a*b*ei(b/294))) - 1))/T^2 == 0;
solT = solve(eqn,T)
Even when I give values for a and b, MATLAb gives me the same message:
syms T
a=(exp(183.8)/1.5);
b=-6.2662e+04;
eqn= (a*b*exp(b/T)*((1 - exp(a*b*ei(b/T) - T*a*exp(b/T))*exp(294*a*exp(b/294) - a*b*ei(b/294))) - 1))/T^2 == 0;
solT = solve(eqn,T)
I would be thankful if someone help me with this.

6 commentaires

darova
darova le 4 Mai 2020
It's too complicated for symbolic calculations. Try numerical - fsolve
I changed my code as follows:
clc
clear all
%Substitute n(T) from the abobe solution into d2n/dT2
syms T
a=(exp(183.8)/1.5);
b=-6.2662e+04;
odefun = @func;
x0 = [300];
x = fsolve(odefun,x0);
% eqn= (a*b*exp(b/T)*((1 - exp(a*b*ei(b/T) - T*a*exp(b/T))*exp(294*a*exp(b/294) - a*b*ei(b/294))) - 1))/T^2 == 0;
%
% solT = solve(eqn,T)
function F = func(x)
a=(exp(183.8)/1.5);
b=-6.2662e+04;
F(1) = (a*b*exp(b/x(1))*((1 - exp(a*b*ei(b/x(1)) - x(1)*a*exp(b/x(1)))*exp(294*a*exp(b/294) - a*b*ei(b/294))) - 1))/x(1)^2 == 0;
end
But it gives the message that "FSOLVE requires all values returned by functions to be of data type double". I don't know why
darova
darova le 5 Mai 2020
Try this
Faezeh Manesh
Faezeh Manesh le 5 Mai 2020
Now it works. But it gives the initial point (x=300) as the final answer which is incorrect.
darova
darova le 5 Mai 2020
I draw you function
a = (exp(183.8)/1.5);
b = -6.2662e+04;
F = @(x) (a*b*exp(b/x)*((1 - exp(a*b*ei(b/x) - x*a*exp(b/x))*exp(294*a*exp(b/294) - a*b*ei(b/294))) - 1))/x^2;
x = linspace(100,400);
y = arrayfun(F,x);
plot(x,y)
% x0 = [300];
% x = fsolve(odefun,x0);
ylim([-1 1]*0.1)
Result
Faezeh Manesh
Faezeh Manesh le 5 Mai 2020
Thanks. Then how can I find the peak? My ultimate goal is to find the peak in terms of a and b

Connectez-vous pour commenter.

Réponses (1)

Steven Lord
Steven Lord le 4 Mai 2020

0 votes

When I display the expression in the Live Editor, I see that the numerator of the expression is the product of a (very large) constant positive value and two exponentials. That numerator, divided by T^2, is supposed to be equal to 0.
The constant is positive. The values of the two exponentials are only 0 in the limit; there's no finite value z for which exp(z) is 0.
So MATLAB correctly gave the answer that there is no solution to your equation as written.
Your expression does look a little unusual, though. Did you intend to have the Ei and one of the exponentials inside the exponent of another exponential call? Maybe there's a parenthesis in the wrong place?

1 commentaire

Faezeh Manesh
Faezeh Manesh le 5 Mai 2020
Actually what I am trying to do is as follows:
I have a diferential equation which has the following form:
when I solved this (with a and b known) and thenfind dy/dT in terms of T, it becomes a figure like this:
I am trying to find the peak in terms of a and b. So, firstly I solved my differential equation symbollicaly in MATLAB to find y(T), then I differentiate dy/dT once more to find dy2/dT2 in terms of y and T. Then I substituted y(T) which had been obtained previously in it. So, my equation would only be in terms of T and then I want to put it equal to zero to find the peak in terms of a and b. but here I substituted my experimental value for a and b o check my answer. So, all I found is from MATLAB

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by