Find unknown from the equation with given value

조회 수: 29 (최근 30일)
Sheryl
Sheryl 2013년 3월 9일
답변: prasad p 2021년 6월 28일
I need to calculate the unknown in the equation, how could i do so using matlab?
this is the equation: c=(1/(tm=60))*(tm*exp(-t/tm)-60*exp(-t/60))
value c and t will be provided
how could find the value tm using matlab?

채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 10일
Using similar ideas to the above:
[...] %define your values for c and t first
syms tm
double( solve( c - ( (1/(tm-60))*(tm*exp(-t/tm)-60*exp(-t/60)) ), tm ) )
or if you have a bunch of these to solve,
syms c t tm
tmfun = matlabFunction( solve( c - ( (1/(tm-60))*(tm*exp(-t/tm)-60*exp(-t/60)) ), tm ), 'vars', {c, t} );
then after that,
tmfun( current_c, current_t )

추가 답변 (2개)

Sven
Sven 2013년 3월 10일
Hi Sheryl, If you have the Symbolic Maths toolbox, you can do something like:
Step 1: Set up your equation. Note that you had "tm=60" inside some parentheses. This seems like a typo... I changed it to "tm-60" instead.
myEqn = sym('c = (1/(tm-60))*(tm*exp(-t/tm)-60*exp(-t/60))')
Step 2: Tell MATLAB two of your variables (say, t=5 and c=45):
newEqn = subs(myEqn,{'t','c'}, [5,45])
Step 3: Ask MATLAB to solve for the remaining term (which is tm):
solve(newEqn)
ans =
-0.59449842358712896610400951227259
Is that what you were trying to do?
  댓글 수: 2
Paige
Paige 2013년 3월 10일
편집: Paige 2013년 3월 10일
Hi, I have tried this and it keeps coming up with the error 'Warning:Explicit solution could not be found', or
1/(lambertw(0, -(703687441776640*exp(-10555311626649600/124074044717989621))/372222134153968863)/5 + 2111062325329920/124074044717989621)
And I have tried to work out what lambertw means with no luck. Why is this?
Thanks in advance

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


prasad p
prasad p 2021년 6월 28일
I want to solve above equation in matlab. I want to slove for unknown value of t4 and t2. But I need the solution t2 and t4 for a range of Please help me to write a code for this in matlab software.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by