1.数值型 roundn—任意位位置四舍五入
>>a=123.4567890;
>>a=roundn(a,-4)
a = 123.4568
其中roundn函数功能如下:
y = ROUNDN(x) rounds the input data x to the nearest hundredth. %不指定n,精确到百分位 y = ROUNDN(x,n) rounds the input data x at the specified power %精确到小数点后指定位数n
2.字符型
>>a=12.34567;
>>b = sprintf('%8.2f',a)
b =12.35 其中b为字符型变量。
3.符号型
vpa(a,n):将a保留小数点后n-1位(使a显示的形式为共有n个数字)
注:vpa命令不能识别整数与小数,只算总位数,结果是符号型变量,即syms型,不能直接进行四则运算!!