MATLAB中digits和vpa
2016-03-15 10:14
393 查看
digits:
DIGITS Set variable precision digits.
Digits determines the accuracy of variable precision numeric computations.
DIGITS, by itself, displays the current setting of Digits.
DIGITS(D) sets Digits to D for subsequent calculations. D is an
integer, or a string or sym representing an integer.
D = DIGITS returns the current setting of Digits. D is an integer.
See also vpa.
vpa:
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]
See also double, digits.
Overloaded methods:
sym/vpa
如:若把b=vpa(0.1666)的结果转换为字符串,可以先将其转换为double类型,即double(b),再num2str(b),即得所需结果。
DIGITS Set variable precision digits.
Digits determines the accuracy of variable precision numeric computations.
DIGITS, by itself, displays the current setting of Digits.
DIGITS(D) sets Digits to D for subsequent calculations. D is an
integer, or a string or sym representing an integer.
D = DIGITS returns the current setting of Digits. D is an integer.
See also vpa.
vpa:
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]
See also double, digits.
Overloaded methods:
sym/vpa
如:若把b=vpa(0.1666)的结果转换为字符串,可以先将其转换为double类型,即double(b),再num2str(b),即得所需结果。
相关文章推荐
- matlab应用初步学习
- matlab应用初步学习
- matlab和C++混编(1)配置开发环境
- 常用的符号运算
- matlab sort()升序和降序
- matlab 串口读取设置
- Matlab实现两个大数相加
- matlab文件批处理
- matlab/simulink学习的笔记都总结在这里
- 最小二乘曲线拟合的MATLAB仿真
- .mat,.txt,.csv 数据转换为weka中的arff格式及matlab和Weka之间相互转换格式
- matlab编程
- NN学习笔记
- MATLAB下载及安装
- 特征提取——生成样本矩阵(MATLAB实现)
- Matlab 视频读写操作
- 分享一个链接 matlab实现QRcode编解码
- MATLAB之极坐标绘图
- 在ubuntu上配置cuda+cudnn+caffe(包括python和matlab接口)+digits
- Matlab R2014+visual studio 2013 混合编程(2)