Hi all,
I'd like to solve the following equation.
sol = [];
for L = -20:10:120
syms x
eqn = 10*log10(10.^(0.1*(norminv(x)*7.6 + 9.88)) + 10.^(0.1*(norminv(x)*6.5 + 12.1)) + 10.^(-0.3)) == L
S = solve(eqn);
sol = [sol S];
end
I modified the equation by replacing the norminv (x) with -sqrt(2)*erfcinv(2*x), i.e.,
sol = [];
for L = -20:10:120
syms x
eqn = 10*log10(10.^(0.1*(-sqrt(2)*erfcinv(2*x)*7.6 + 9.88)) + 10.^(0.1*(-sqrt(2)*erfcinv(2*x)*6.5 + 12.1)) + 10.^(-0.3)) == L
S = solve(eqn);
sol = [sol S];
end
However, I got a warning saying, "Warning: Unable to find explicit solution. For options, see help.". So, I add the following lines, hoping to solve the equation, but still unsuccessful.
S = solve(eqn);
string(lhs(eqn)-rhs(eqn))
sol = [sol vpasolve(eqn, [-143, -109.5937])]
Could someone please help me out?
Thanks in advance

 Réponse acceptée

syms x
eqn = 10*log10(10.^(0.1*(-sqrt(2)*erfcinv(2*x)*7.6 + 9.88)) + 10.^(0.1*(-sqrt(2)*erfcinv(2*x)*6.5 + 12.1)) + 10.^(-0.3))
eqn = 
double(limit(eqn, x, 1e-200))
ans = -3.0000
double(limit(eqn, x, 1-sym(1e-50)))
ans = 123.5352
The left hand side is the same for all of them, and you cannot get it down below -3 and cannot get it much above 120-ish. So there is no real-valued solution for L = -20 or L = -10
For the other values... use vpasolve() with around 0.01 as an initial guess, and after that use the previous solution as the initial guess for the next round.

9 commentaires

Susan
Susan le 1 Mar 2023
Modifié(e) : Susan le 1 Mar 2023
@Walter Roberson Thank you so much for your response. I modified the code as follows
sol = [];
InitialGuess = 0.01;
for L = -2:2:123
syms x
eqn = 10*log10(10.^(0.1*(-sqrt(2)*erfcinv(2*x)*7.6 + 9.88)) + 10.^(0.1*(-sqrt(2)*erfcinv(2*x)*6.5 + 12.1)) + 10.^(-0.3)) == L
sol = [sol vpasolve(eqn, InitialGuess)];
InitialGuess = sol;
end
figure;
cdfplot(sol)
grid on
but I get the error, "Starting points or search ranges are incompatible with the variables." Could you please point out what I'm doing wrongly?
sol = [];
InitialGuess = 0.01;
syms x
expr = 10*log10(10.^(0.1*(-sqrt(2)*erfcinv(2*x)*7.6 + 9.88)) + 10.^(0.1*(-sqrt(2)*erfcinv(2*x)*6.5 + 12.1)) + 10.^(-0.3));
for L = -2:2:123
thissol = vpasolve(expr == L, InitialGuess);
if isempty(thissol)
sol(end+1) = NaN;
else
sol(end+1) = double(thissol);
InitialGuess = thissol;
end
end
figure;
cdfplot(sol)
grid on
Susan
Susan le 1 Mar 2023
@Walter Roberson thank you so much for your help. Appreciate it!
Sorry if I'm asking about the obvious, but could you please tell me how I can plot the cdf of ''sol" values versus the L? (x-axis are L values)
Torsten
Torsten le 1 Mar 2023
Modifié(e) : Torsten le 1 Mar 2023
I think the sol-values themselves are a cdf, aren't they ?
syms x L
eqn = 10*log10(10.^(0.1*(-sqrt(2)*erfcinv(2*x)*7.6 + 9.88)) + 10.^(0.1*(-sqrt(2)*erfcinv(2*x)*6.5 + 12.1)) + 10.^(-0.3)) == L;
L_num = -1:50;
x0 = 0.0001;
for i = 1:numel(L_num)
x_sol(i) = double(vpasolve(subs(eqn,L,L_num(i)),x,x0));
x0 = x_sol(i);
end
plot(L_num,x_sol)
Susan
Susan le 1 Mar 2023
@Walter Roberson Yes! This is what I expected. Thank you so much again for your help!
I think it was @Torsten that gave that reply ;-)
Susan
Susan le 1 Mar 2023
Modifié(e) : Susan le 1 Mar 2023
@Torsten Thank you so much for your response! It is what I was looking for. :)
If you don't mind, I've got another question for you. I'm trying to solve the above equation in a for loop. The constant values in the equation change a bit. But I get the following error.
Unable to perform assignment because the left and right sides have a different number of elements.
Error in test (line 104)
x_sol(i) = double(vpasolve(subs(eqn,L,L_num(i)),x1,x0));
It seems double(vpasolve(subs(eqn,L,L_num(ii)),x1,x0)) is a "0×1 empty double column vector". Any thoughts?
Susan
Susan le 1 Mar 2023
@Walter Roberson Got you! Thans again

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics 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