I want to solve for t in the equation: Tf=Ts+(T0-Ts)*exp(-k*t), but I can't figure out how to solve for t. I can only solve for Tf. Here is my script. What do I need to add/change to solve for t?
T0=120;
Ts=38;
k=0.45;
Tf=65;
Tf=Ts+(T0-Ts)*exp(-k*t)

 채택된 답변

Star Strider
Star Strider 2020년 1월 23일

0 개 추천

Use a root-finding function (I chose fzero here), then take the known variable values, create an anonymous function from the expression for ‘Tf’ and solve:
T0=120;
Ts=38;
k=0.45;
Tf=65;
% Tf=Ts+(T0-Ts)*exp(-k*t);
[tval,fval] = fzero(@(t) Ts+(T0-Ts)*exp(-k*t)-Tf, 1)
producing:
tval =
2.4686

댓글 수: 3

Maddie Sanders
Maddie Sanders 2020년 1월 23일
Thank you!
What does tval and fval represent, and where did you get the valye of 1 in the parenthesis.
Star Strider
Star Strider 2020년 1월 23일
My pleasure!
The ‘tval’ output is the value of ‘t’ where the expression equals ‘Tf’, and the ‘fval’ output is the value of the function at that point, indicating that it found a ‘t’ value that resulted in the anonymous function being very close to zero (within the tolerance fzero uses). Every nonlinear parameter estimation function requires an initial estimate for the parameter (or parameters) it is estimating, and I chose 1 here. The initial parameter estimates can be important in some problems, however not in this one, where widely differing iinitial estimates all produce the same result for ‘tval’.
Star Strider
Star Strider 2020년 1월 23일
If my Answer helped you solve your problem, please Accept it!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

질문:

2020년 1월 23일

댓글:

2020년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by