How to Reduce precision in symbolic calculations? I am finding y coordinates of a function using the given values of x, but i need a precision of only 6 digits whereas it is showing precision of upto 32 digits. Is there any way to reduce this.

1 回表示 (過去 30 日間)
I have written this code
F(x)=str2sym(input('\n Enter your Function \n','s'));
n=5;
for i=1:n
Xc(n-i+1)=cos((2*i-1)*pi/(2*n));
Yc(n-i+1)=F(Xc(n+1-i));
end
Output for Yc i am getting like this
464117984467495032381892722260990947504936973669843836644757151680908531146350992264046993107726927583732093218310834812684079069294231552/168985358144614903155245222233811487413573432092325201308884315904260130151775076057502118851573812559523911443976373100061575749702154875

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 20 日
You can use vpa()
vpa(Yc, 6)
  2 件のコメント
Harsh Mittal
Harsh Mittal 2020 年 11 月 20 日
does this works for symbolic functions with variable 'x', because i am further using value of Yc in calculations?
Harsh Mittal
Harsh Mittal 2020 年 11 月 20 日
It worked thanks for the help!!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by