Odd warning bug on MATLAB
    4 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    SooShiant
 le 25 Sep 2015
  
    
    
    
    
    Réponse apportée : Walter Roberson
      
      
 le 25 Sep 2015
            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
0 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 25 Sep 2015
        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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

