help with expressing a function

2 ビュー (過去 30 日間)
Jama Ali
Jama Ali 2020 年 10 月 11 日
回答済み: Walter Roberson 2020 年 10 月 11 日
Hi, can someone please explain why i get this and not, 0.006366*cos(t)?

採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 11 日
syms t
sym(2/pi*0.01, 'd') * cos(t)
ans = 
0.006366197723675814240662518272984cos(t)
The reason you are getting what you are getting, is that the default symbolic conversion of floating point number to symbolic number, is for the floating point number to be converted to rational. Well, not really rational as such: it is extended to include sqrt(), and pi.
You can specifically tell MATLAB to convert floating point into software floating point by using the 'd' flag.
Or you can convert after the fact by using vpa() on the result you got.

その他の回答 (1 件)

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2020 年 10 月 11 日
try this:
vpa(2/pi*0.01*cos(t),6)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by