符號計算問題。

4 views (last 30 days)
dutoga
dutoga on 28 Oct 2022
Answered: hovers on 28 Oct 2022
想請問一下,我寫了以下的碼
T = input('Key in Period , T= ');
d = input('Key in water depth , d= ');
w=(2*pi)/T;g=9.8;dk=0.1;
syms k;
f=g*k*tanh(k*d)-w^2;
df=diff(f)
k = input('Key in initial k, k= ');
df=subs(df)
在這裡我把 T,d,k 都是輸入10
輸出結果如以下
Key in Period , T= 10
Key in water depth , d= 10
df =
(49*tanh(10*k))/5 - (49*k*(10*tanh(10*k)^2 - 10))/5
Key in initial k, k= 10
df =
(49*tanh(100))/5 - 980*tanh(100)^2 + 980
f =
98*tanh(100) - 3555899736243219/9007199254740992
以上是輸出的結果
我想請問一下有沒有辦法把 df 跟 f的值,直接的計算出來
而不是這樣的情況
(49*tanh(100))/5 - 980*tanh(100)^2 + 980
98*tanh(100) - 3555899736243219/9007199254740992
麻煩一下了 謝謝

Accepted Answer

hovers
hovers on 28 Oct 2022
df = vpa(df)
f = vpa(f)

More Answers (0)

Categories

Find more on 安装和许可简介 in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!