MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Evaluating an implicit equation, with multiple parameters that can be modified

Asked by Chris on 9 Jul 2012

Hey all, I'm still learning many MATLAB functions so it's possible this just needs simple answer. Haven't been able to find it on my own though, so any help is greatly appreciated.

I have a function that depends on several parameters. I want to be able to define all but one parameter and then have MATLAB output the remaining parameter value.

More specifically, for instance, if I: (1) have the equation below, (2) want to solve for tm, and (3) have parameters b, tp, & a (that I'd like to ultimately try different values for),

(b^2/6)*((tm-tp)^(-1)-(tm^-1))/(log(tm)-log(tm-tp))-a = 0

what's the best way to define the parameters (b, tp, a) and then get the value of tm?

Right now I only have a really clunky method, below. Which is sort of ok for this, but will not work well when I move on to my next equation, which has more variables and an integral...

...

syms tm

S = solve('(b^2/6)*((tm-tp)^(-1)-(tm^-1))/(log(tm)-log(tm-tp))-a','b=.0015', 'tp=1', 'a=1.47e-7');

S = [S.tm S.tp S.b S.alph];

disp(S(1))

...

Thanks for any helpful ideas! Chris

## Products

No products are associated with this question.

Answer by proecsm on 9 Jul 2012
```clc;clear
b = .0015;
tp = 1;
a = 1.47e-7;
```
```f = @(tm)(b^2/6)*((tm-tp)^(-1)-(tm^-1))/(log(tm)-log(tm-tp))-a;
```
```tm = fzero(f,2.7);
```
```tm =
```
`      3.1152`