How to change output format from solve function

5 次查看(过去 30 天)
Hello,
I would like to change the output format from the solve equation.
For instance in this simple example:
syms d
dist = solve(115.7==20*log10(4*pi*d/lambda)-10*log10(Gr)-10*log10(Ge)-2.2,d)
I get as answer:
dist = 10^(691379199349428923/112589990684262400)/(24*pi)
What command could I use to receive
dist = 1.8337e+04
Thanks you.

采纳的回答

Stephan
Stephan 2020-11-12

更多回答(1 个)

Walter Roberson
Walter Roberson 2020-11-12
Your use of 115.7 and 2.2 in the equation tells us that you are working with values that are fundamentally not exact. 115.7 here expresses "some indeterminate value that is between 11565/100 (inclusive) and 11575/100 (exclusive)" . As such it does not make sense to ask for an exact solution. solve() is for use in cases where you want indefinitely precise solutions, which is not the case here. You should be using vpasolve() instead.
If for some reason you believe that 115.7 is exactly 1157/10 then you should be using
syms d
Q = @(v) sym(V); %convert to symbolic algebraic number
dist = solve( Q(115.7) == Q(20)*log10(Q(4)*Q(pi)*d/lambda) - Q(10)*log10(Gr)-Q(10)*log10(Ge)-Q(2.2), d)
... and expect an exact solution formula. Which you could then vpa() or double() to see an approximation of.
The calls to Q() there are to convert floating point numbers into the closest algebraic number (or into Pi), such as 115.7 -> 1157/10 and 1.4142135623731 -> 2^(1/2)
  1 个评论
Quentin Dragomir
Quentin Dragomir 2020-11-12
I'm not sure to understand the differences between solve and vpasolve.
I could rewritte my equation to have :
dist = solve(117.9==20*log10(4*pi*d/lambda)-10*log10(Gr)-10*log10(Ge),d)
Here I should obtain an exact solution

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by