I am trying to solve fsolve (multi-variable) but getting an error.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dhawal Beohar
le 16 Fév 2022
Commenté : Walter Roberson
le 17 Fév 2022
function fval = func4uo(u)
d1=1;
n=1;
m=1;
a=1;
T=1;
PsByN_0=1;
fval = ((-1/u)*log((d1^m)/(a*n*PsByN_0*T*u)+d1^m)*a*T)/(1-a)*T;
xsol = fsolve (@(u) func4uo(u), 0)
ERROR: Not enough input arguments.
14 commentaires
Réponse acceptée
Matt J
le 16 Fév 2022
By choosing a=1, you are dividing by 1-a=0 for any input value, u.
f(0), f(1), f(2)
function fval = f(u)
d1=1;
n=1;
m=1;
a=1;
T=1;
PsByN_0=1;
fval = ((-1/u)*log((d1^m)/(a*n*PsByN_0*T*u)+d1^m)*a*T)/(1-a)*T;
end
0 commentaires
Plus de réponses (2)
Walter Roberson
le 17 Fév 2022
There is no zero for that function.
If you use negative u, then the imaginary component of the function approaches negative infinity as u gets close to zero, and only reaches zero again as u gets to -infinity.
If you use positive u and floating point values, then the expint() overflows to infinity when you reach about 8, and the exp() term numerically goes to 0 in floating point, and inf*0 is nan.
If you use positive u with the symbolic toolbox, you can show that the real part of the function is negative until infinity is reached.
Or perhaps I should say that the root is u = +inf as in the limit the function does become 0.
format long g
U = linspace(5,8);
Z = func4uo(U);
figure(); plot(U, real(Z), 'k'); title('real'); xlim([0 10])
figure(); plot(U, imag(Z), 'r'); title('imaginary'); xlim([0 10])
func4uo(10)
func4uo(sym(10))
vpa(ans)
syms u
Z = func4uo(u)
limit(Z, u, inf)
vpa(ans)
function fval = func4uo(u)
d1=10;
n=10^-11.4;
m=2.7;
a=0.5;
T=1;
PsByN_0dB=20;
PsByN_0=10.^(PsByN_0dB/10);
fval = ((-1./u).*log((d1.^m)./(a.*n.*PsByN_0.*T.*u)+d1.^m).*a.*T)./(1-a).*T - (1./u).*log(expint(-PsByN_0.*u)).*exp(-PsByN_0.*u);
end
Walter Roberson
le 17 Fév 2022
Modifié(e) : Walter Roberson
le 17 Fév 2022
Z = @(PS) arrayfun(@(ps) fzero(@(u)func4uo(u,ps), [0.6775499178144678 1e3]), PS)
P = linspace(-5, 1);
syms u
F = func4uo(u, P(1))
string(F)
%vpasolve(F)
%{
U = Z(P);
plot(P, real(U), 'k', P, imag(U), 'r');
xlabel('Ps'); ylabel('u')
%}
function fval = func4uo(u,Ps)
d1=10;
n=10^-11.4;
m=2.7;
a=0.5;
T=1;
PsByN_0dB=20;
PsByN_0=10.^(PsByN_0dB/10);
fval = ((-1./u).*log((d1^m)./(a.*n.*PsByN_0.*T.*u)+d1.^m).*a.*T)./(1-a).*T - (1./u).*log(expint(-Ps.*u)).*exp(-Ps.*u);
end
5 commentaires
Walter Roberson
le 17 Fév 2022
In your other Question I show that your revised code has no root (unless you count u = infinity)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




