Newton's Method to Solve Equation

1 回表示 (過去 30 日間)
Tyler Bodnarik
Tyler Bodnarik 2021 年 9 月 12 日
回答済み: Yongjian Feng 2021 年 9 月 12 日
I trying to write a code to solve an equation using newton's method and given three inputs.
So far I have
syms L h T g
f_L = L-g*T*T/(2*pi)*tanh(2*pi*h/L)
Df = diff(f_L,L)
The variable Df is in symbolic form but I need to convert it to numeric. Any ideas how to do this?
Thank you

回答 (1 件)

Yongjian Feng
Yongjian Feng 2021 年 9 月 12 日
You need to substitute symbols with values, right?
L = 1.0;
h = 2.0;
T = 3.0;
g = 9.8;
% substitute
ret = subs(Df);
% convert
res = double(ret);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by