How to evaluate the value of Symbolic Expressions

3 ビュー (過去 30 日間)
Shree Nath
Shree Nath 2013 年 6 月 5 日
I tried this code -
syms f(a) g(b)
f(a)=sin(a);
g(b)=exp(b);
disp(f(2));
disp(g(4));
syms h(a,b);
h(a,b)=diff(f(a),a)*diff(g(b),b);
disp(h(2,4));
but it doesnt return the values of sin(2) and exp(4); It just returns sin(2) and exp(4). It gives values of algebraic expressions, but not trigonometric and exponential functions. How to calculate the values?? Please Help.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 5 日
f=@(a) sin(a);
g=@(b) exp(b);
disp(f(2));
disp(g(4));
  6 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 5 日
syms a b
f=sin(a);
g=exp(b);
double(subs(f,2))
double(subs(g,2))
h=diff(subs(f,a),a)*diff(subs(g,b),b);
a=2;
b=4;
double(subs(h));
Shree Nath
Shree Nath 2013 年 6 月 5 日
Got it. Thanks. double() also Worked. :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by