Find unknown from the equation with given value

29 views (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 10 Mar 2013
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 )

More Answers (2)

Sven
Sven on 10 Mar 2013
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 Comments
Paige
Paige on 10 Mar 2013
Edited: Paige on 10 Mar 2013
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

Sign in to comment.


prasad p
prasad p on 28 Jun 2021
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.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!