Matlab is rounding all answers to 4dp when I use syms.

4 ビュー (過去 30 日間)
redman
redman 2021 年 3 月 3 日
編集済み: Rashed Mohammed 2021 年 3 月 8 日
Matlab keeps rounding my outputted values in the command window to 4dp, I've looked all over mathworks and I can't find a solution to my problem in particular. Does anyone know how I can fix this?
syms x n
f(x) = (2/sqrt(pi))*symsum(((-1)^n * x^(2*n +1))/((2*n+1)*factorial(n)),n,0,100);
f(0.1)
ans =
0.1125

回答 (1 件)

Rashed Mohammed
Rashed Mohammed 2021 年 3 月 8 日
編集済み: Rashed Mohammed 2021 年 3 月 8 日
Hi John,
Assuming you have set the preference option "FloatingPointOutput" to true in sympref, the output will be fixed-decimal format with 4 digits after the decimal point. If you need to change the number of digits after the decimal point, consider using vpa function with the number of significant digits you need.
Hope this helps.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by