你好,我有一个问题。当我在 matlab 中计算除法时: x/(pi.^2)
syms x
x/(pi.^2)
ans =
(281474976710656*v)/2778046668940015
正确答案是 x/9.8696,为什么 matlab 给我这个结果?
这是一个错误吗?
最佳答案
您必须使用 vpa() 命令“可变精度算术”。检查这段代码:
syms x real; % define x as a real symbolic variable (not a complex variable)
vpa( x/(pi.^2), 5) % second argument define number of significant digits
对于涉及 pi 的三角函数表达式,有时最好定义 sym('pi'):
syms x real;
pi_s = sym('pi');
expr = x/pi_s^2
我尝试在使用符号工具箱时始终使用“真实”标签。如果您不使用它,您将看到很多复数共轭和其他对您的问题不重要的东西,因为 x 可能是实变量。
希望对您有所帮助,
关于matlab - Pi, Matlab 符号数学工具箱有错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12920998/