vpa函数有两种语法格式:
vpa(x)
vpa(x,d)
下面是MATLAB帮助文档上的解释:
vpa(x) uses variable-precision floating-point arithmetic (VPA) to evaluate each element of the symbolic input x to at least d significant digits, where d is the value of the digits function. The default value of digits is 32.
vpa(x,d) uses at least d significant digits, instead of the value of digits.
从上述描述大概知道,vpa(x)需要配合函数digits实用,实用digits来设定精度值。
例如:
>> doc vpa
>> digits(3)
>> vpa(pi)
ans =
3.14
我们也可以使用第二种语法格式来设定精度,例如:
>> vpa(pi,5)
ans =
3.1416
又例如:
Find π to 100 significant digits by specifying the second argument.
vpa(pi,100)
ans =
3.141592653589793238462643383279502884197169...
39937510582097494459230781640628620899862803...
4825342117068
大概了解下就这些,详细内容在MATLAB命令框中输入doc vpa看详细解释。
本文同步分享在 博客“李锐博恩”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。