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

7 次查看(过去 30 天)
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

采纳的回答

bym
bym 2012-7-9
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

更多回答(1 个)

Chris
Chris 2012-7-11
Thanks mucho!

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by