您的位置:首页 > 编程语言 > MATLAB

matlab数据类型转换遇到问题,及解决办法,sym,double ,vpa转换

2015-08-15 16:15 721 查看
符号计算与数值计算混合使用是Matlab程序的大忌!

丧失了快速计算得优点!




vpa

Variable precision arithmetic

变量精度计算

Syntax

R = vpa(A)

R = vpa(A, d)

Description

R = vpa(A) uses variable-precision arithmetic (VPA) to compute each element of A to d decimal digits of accuracy, where d is
the current setting of digits. Each element of the result is a symbolic expression_r.

R = vpa(A, d) uses d digits, instead of the current setting of digits.

R = vpa(A)利用变量精度计算方法以d为小数点精度去计算A中的每个元素,其中d是当前的小数点设置(digits).每个输出的元素是符号表达式.

R = vpa(A, d) 利用d为digits精度代替当前的digits设置.(其实就是小数点后的位数)

Examples

The statements
digits(25) q = vpa(sin(sym('pi')/6)) p = vpa(pi) w = vpa('(1+sqrt(5))/2')


return
q = 0.5 p = 3.141592653589793238462643 w = 1.618033988749894848204587


vpa pi 75 computes π to 75 digits.

The statements
A = vpa(hilb(2),25) B = vpa(hilb(2),5)


return
A = [ 1.0, 0.5] [ 0.5, 0.3333333333333333333333333] B = [ 1.0, 0.5] [ 0.5, 0.33333]

matlab错误提示

The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.

If the input expression contains a symbolic variable, use the VPA function instead.

Error in hRefinement2d (line 103)
newprojcoord(wcpindex,:) = tempcontrolPoints;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: