How do I solve for a variable?

조회 수: 7 (최근 30일)
Jason Cardillo
Jason Cardillo 2016년 2월 9일
댓글: Walter Roberson 2016년 2월 10일
I am trying to solve for a variable, and I'm pretty sure I have the code written correctly but for some reason it doesn't like it. I wrote:
syms x
eqn = 2943*log((2943*x-1)/(2943*0.2*x)) + 2305.35*log((2305.35*x-1)/(2305.35*0.3*x)) == 6.2;
solve(eqn,x)
but it gives me this response in the command window:
Warning: Possibly spurious solutions. [solvelib::checkSolutions]
ans =
RootOf(some infinitely long number)
Any ideas?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 2월 9일
Does the first 2305.35 mean 230535/100, or does it mean 230535/100 +/- 5/1000 ? Does the second 2305.35 mean the same structure as the first? If so then in the +/- case could the second 2305.35 be towards the top end of the 230535/100 + 5/1000 range but the first one be near the bottom of the 230535/100 - 5/1000 range?
Is the 0.2 the same thing as 1/5 or does it mean 1/5 +/- 5/100 or does it mean 1/5 +- 2^(-55) (the normal MATLAB interpretation) ?
Basically, if you have a floating point number in your equation, you should not be using solve() because solve() is for exact algebraic solutions, and exact algebraic solutions are GIGO (Garbage In, Garbage Out) when the inputs are imprecise. In such cases you should use vpasolve() to look for a [software] numeric solution.
When I convert the numbers as if the decimal places were exact numbers, the symbolic package I am using is taking a fair time to come up with a solution.
  댓글 수: 2
Jason Cardillo
Jason Cardillo 2016년 2월 9일
Yeah those are decimal points, so it should be 1/5 and I'm not sure what the 2305.35 would be as a fraction.
So if that doesn't work I don't quit understand what I need to do in order to make it work. Can you help me with that?
Walter Roberson
Walter Roberson 2016년 2월 10일
Instead of using
solve(eqn,x)
use
vpasolve(eqn,x)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by