Odd warning bug on MATLAB

2 次查看(过去 30 天)
Hi
Yesterday I installed MATLAB and try to solve an equation using this command:
solve('(L*Y*X*D)+(K*(S-A))+(F*X*T)-(F*(H-X)*T)=N','X')
and MATLAB answered me:
((N + K*(A - S) + F*H*T)/(2*F*T + D*L*Y))
I copied both question and answer to a text document and repeated this process for several times to ensure the result is OK. I mean copy-pasted this process for several times.
Then I tried a very big equation (20 lines with 50 variables) and MATLAB answered it too in a second.
Now today I tried those equations using copy-past and do the same way but MATLAB oddly says:
>> solve('(L*Y*X*D)+(K*(S-A))+(F*X*T)-(F*(H-X)*T)=N', 'X')
Warning: Explicit solution could not be found.
> In solve at 179
ans =
[ empty sym ]
How to fix this bug?
thanks for help

采纳的回答

Walter Roberson
Walter Roberson 2015-9-25
solve('(L*Y*X*D)+(K*(S-A))+(F*X*T)-(F*(H-X)*T)=N', 'X')
is equivalent to
solve(sym('(L*Y*X*D)+(K*(S-A))+(F*X*T)-(F*(H-X)*T)=N'), sym('X'))
so (L*Y*X*D)+(K*(S-A))+(F*X*T)-(F*(H-X)*T)=N would get evaluated as a symbolic expression inside the symbolic engine. The result of that is going to depend upon whether you have accidentally told the symbolic engine to define some of those names already.
For example,
syms X(V)
would define X as a function, and then the meaning of X as being a function would be inherited when you did the solve() of a string. And that could fail due to difficulties in solving with respect to a function.

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by