matlab中怎么保留有效位数?

love_yjh 2017-07-26 10:28:55
比如,a=12.3648;如果我想取前三位,怎么得到a=12.3?求大神解答
...全文
3129 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
灌水号 2017-07-26
  • 打赏
  • 举报
回复
vpa Variable precision arithmetic. R = vpa(S) numerically evaluates each element of the double matrix S using variable precision floating point arithmetic with D decimal digit accuracy, where D is the current setting of DIGITS. The resulting R is a SYM. vpa(S,D) uses D digits, instead of the current setting of DIGITS. D is an integer or the SYM representation of a number. It is important to avoid the evaluation of an expression using double precision floating point arithmetic before it is passed to vpa. For example, phi = vpa((1+sqrt(5))/2) first computes a 16-digit approximation to the golden ratio, then converts that approximation to one with d digits, where d is the current setting of DIGITS. To get full precision, use unevaluated string or symbolic arguments, phi = vpa('(1+sqrt(5))/2') or s = sym('sqrt(5)') phi = vpa((1+s)/2); Additional examples: vpa(pi,780) shows six consecutive 9's near digit 770 in the decimal expansion of pi. vpa(hilb(2),5) returns [ 1., .50000] [.50000, .33333]
赵4老师 2017-07-26
  • 打赏
  • 举报
回复
变成字符串,再变回数?
love_yjh 2017-07-26
  • 打赏
  • 举报
回复 1
输入的是double型数据,想要输出也是double型数据。

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧