Warning: Explicit solution could not be found.

1 vue (au cours des 30 derniers jours)
Bart
Bart le 21 Déc 2011
>> syms x
>> total = 0;
>> t2 = 0;
>> t=0;
* >> p = 4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t);*
>> help = 0;
>> for i = 1:2
*t2 = double(solve('4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t)-p','t'));*
p = 4.8825*exp(-0.0954*(t2+4.77))+ 12.845*exp(-0.0006211*(t2+4.77));
total = total + double(int(4.8825*(exp(-0.0954*x)+12.845/4.8825*exp(-0.0006211*x)),x,t2,t2+4.77));
t=t+9.4446;
end
Warning: Explicit solution could not be found.
> In solve at 81
Hei, I got this problem with the above loop. I think the problem occurs when I try to assign a value to p; and then chuck it in solve('...').
I need to solve both these equation simultaniously though, and I have no idea of how to get there otherwise. Anybody care to shed some light on this? All help is greatly appreciated :)
  1 commentaire
Bart
Bart le 21 Déc 2011
I cried victory too soon :D.
I get this error on the second cycle:
>> syms x
>> total = 0;
>> t=0;
>> t2 = 0;
>> p = 4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t);
>> for i=1:159
t2 = double(solve(4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t)-p,'t'));
p = double(4.8825*exp(-0.0954*(t2+4.77))+ 12.845*exp(-0.0006211*(t2+4.77)) + 0.05262*4.4253);
total = total + double(int(4.8825*(exp(-0.0954*x)+12.845/4.8825*exp(-0.0006211*x)),x,t2,t2+4.6059));
end
??? Error using ==> solve>getEqns at 178
' 1.590127e+000 ' is not a valid expression or equation.
Error in ==> solve at 67
[eqns,vars] = getEqns(varargin{:});
How do I use sprintf then in this case?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Déc 2011
Instead of
t2 = double(solve('4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t)-p','t'));
use
t2 = double(solve(4.8825*exp(-0.0954*t)+ 12.845*exp(-0.0006211*t)-p,'t'));
Otherwise it will not pick up the value of p from the MATLAB variable you assigned earlier.
  6 commentaires
Bart
Bart le 21 Déc 2011
how could I incorporate sprintf in the above for-loop? I think the error comes forth from the calculation of 't' in the 'solve()' function. But I have no idea how I could implement sprintf in that case.
Walter Roberson
Walter Roberson le 21 Déc 2011
The real problem is that you are re-using variable names. You have t=0 and then in t2 you want to solve for t -- but t is 0. This leaves you trying to solve a constant rather than an expression.
Your expression for p calculates a particular expression when t=0, and then in t2 you are trying to solve the same expression minus p to get t out. If t was symbolic there, of course the solution is going to be t=0

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by