Trying to solve a log equation with one variable help! ERROR: 1 equations in 2 variables. New variables might be introduced.

1 view (last 30 days)
Hey, I'm trying to solve for one variable, T in two log functions.
syms T
pstarS=10^(7.06623-(1507.434/(T+214.979)))
pstarT=10^(6.95185-(1346.773/(T+219.693)))
total=pstarS+pstarT
eqn1=total==1
eval(solve(eqn1,T,65))
I'm really new to matlab, and this is the general form my prof used to solve example equations. I'm trying to solve for T, and matlab also warns me that 'an explicit solution could not be found'. I'm lost trying to troubleshoot this, any help would be great, thanks!

Accepted Answer

Star Strider
Star Strider on 20 Jun 2015
Edited: Star Strider on 20 Jun 2015
The correct syntax is:
syms T
pstarS=10^(7.06623-(1507.434/(T+214.979)));
pstarT=10^(6.95185-(1346.773/(T+219.693)));
total=pstarS+pstarT;
eqn1=total==1
T = solve(eqn1, T)
(the eval call not being necessary) but that's still taking the long way round.
A more direct implementation would use anonymous functions for pstarS, pstarT and total, and the fzero function for the solution:
pstarS = @(T) 10^(7.06623-(1507.434/(T+214.979)));
pstarT = @(T)10^(6.95185-(1346.773/(T+219.693)));
total = @(T) pstarS(T)+pstarT(T) - 1;
T = fzero(total, 1)
both producing:
T =
-27.3354
EDIT — What your professor wants will not make it so, at least with those equations.
The plots:
pstarS = @(T) 10.^(7.06623-(1507.434./(T+214.979)));
pstarT = @(T)10.^(6.95185-(1346.773./(T+219.693)));
total = @(T) pstarS(T) + pstarT(T) - 1;
T = linspace(0,100,250);
figure(1)
plot(T, total(T), T, pstarS(T), T, pstarT(T))
grid
legend('total', 'pstarS', 'pstarT', 'Location','NW')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!