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.
0 个评论
采纳的回答
更多回答(1 个)
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!