符号运算得到的是精确的解析解,但是有时需要进行数值转换,主要通过以下几个函数实现。
1.digits 函数
调用方法:digits(D)
函数设置有效数字个数为D的近似解精度。
2.vpa 函数
vpa
Variable-precision arithmetic
Syntax
R = vpa(A)
R = vpa(A,d)
Description
R = vpa(A) uses variable-precision arithmetic (VPA) to compute
each element of A to at least d decimal digits of accuracy, where d
is the current setting of digits.
R = vpa(A,d) uses at least d significant (nonzero) digits,
instead of the current setting of digits.
注:vpa中的精度是指有效值,即vpa(1.2345,2)=1.2;vpa(0.2345,2) = 0.23
3.subs函数
subs
Symbolic substitution
Syntax
g = subs(f,old,new)
g = subs(f,new)
g = subs(f)
g = subs(f,old,new,0)
Description
g = subs(f,old,new) repl