MATLAB中的vpa函数简单实用记录——精度控制

版权声明:本博客内容来自于个人学习过程中的总结,参考了互联网、数据手册、帮助文档、书本以及论文等上的内容,仅供学习交流使用,如有侵权,请联系,我会重写!转载请注明地址! https://blog.csdn.net/Reborn_Lee/article/details/87371080

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看详细解释。

猜你喜欢

转载自blog.csdn.net/Reborn_Lee/article/details/87371080
今日推荐