如何在Matlab中将符号表达式舍入为N位数

时间:2017-02-25 04:12:15

标签: matlab rounding symbols

当您尝试将符号表达式舍入为N位数时,您会收到以下错误消息:

>> format long
>> syms x;
>> round(x, 10)
Error using sym/round
Too many input arguments.
>> round(vpa(pi), 10)
Error using sym/round
Too many input arguments.

那你怎么做这个呢?

1 个答案:

答案 0 :(得分:0)

这是你的工作方式

>> syms x; N = 6;
>> round(pi*10^N)/vpa(10^N)

ans =

3.141593
>> round(x*10^N)/vpa(10^N)

ans =

0.000001*round(1000000*x)