how to get function value?

Hi I want to evaluate function and its derivative at a=2 , how to do that?
syms a
b=2
e=0.9
q=1.2
g=2
k=3
d=0.5
f=(q*b*e/a-d*e)/((q^2)*(e^2)/a+2*e*g)
diff(f)

 采纳的回答

df(a) = diff(f)
df(2)

5 个评论

thank you! and what about function ?
I do f(2) but it doesn't work
P.S: You have some troubles with copying.
f(a) = (q*b*e/a-d*e)/((q^2)*(e^2)/a+2*e*g)
f(2)
oh I'm so bad at matlab :D .. thank you

请先登录,再进行评论。

更多回答(1 个)

syms a;
b=2;
e=0.9;
q=1.2;
g=2;
k=3;
d=0.5;
f=(q*b*e/a-d*e)/((q^2)*(e^2)/a+2*e*g);
df=diff(f);
fvals=eval(subs(f,1:10));%evaluate f from 1:10 (if you want actual symetric value eleminate the eval function
dfvals=eval(subs(df,1:10));

3 个评论

does eval give approximate value or exact value/?
Nah using eval(...) is o]absolutely not needed here! forget it!
I agree,, David Hill , thanks for the effort, but I think I'll go with the other answer, sorry

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by