- 积分
- 3
- 注册时间
- 2008-7-25
- 仿真币
-
- 最后登录
- 1970-1-1
|
首先说明一下,使用的函数是subs,如果你已经知道了,就没必要继续往下看了,浪费时间,O(∩_∩)O
首先是调用格式: 代码:R = subs(S)
R = subs(S, new)
R = subs(S, old, new)
其中S为符号表达式,默认的是变量x!
下面看几个例子,相信大家就是使用了!
例1: 代码:>> syms x;
>> f=x^2;
>> subs(f,2)
ans =
4
例2:将表达式x^2+y^2中x取值为2 代码:>> syms x y;
>> f=x^2+y^2;
>> subs(f,x,2)
ans =
y^2 + 4
例3: 代码:>> syms x y;
>> f=x^2+y^2;
>> subs(f,findsym(f),2)
ans =
y^2 + 4
其中findsym(f)为查找f中所有的符号变量
例4:同时对两个或多个变量取值求解 代码:>> syms a b;
subs(cos(a) + sin(b), {a, b}, {sym('alpha'), 2})
ans =
sin(2) + cos(alpha)
例5:带入数据的值也可以是数组形式 代码:
>> syms t a;
>> subs(exp(a*t), 'a', -magic(2))
ans =
[ 1/exp(t), 1/exp(3*t)]
[ 1/exp(4*t), 1/exp(2*t)] |
评分
-
1
查看全部评分
-
|