MATLAB中的vpa函数简单实用记录——精度控制
vpa函数有两种语法格式:
vpa(x)
vpa(x,d)
下面是MATLAB帮助文档上的解释:
vpa( uses variable-precision floating-point arithmetic (VPA) to evaluate each element of the symbolic input x)x to at least d significant digits, where d is the value of the digits function. The default value of digits is 32.
vpa( uses at least x,d)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看详细解释。
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/87371080
- 点赞
- 收藏
- 关注作者
 
             
           
评论(0)