请教如何用matlab解隐性方程:y=((9.8*T^2)/2*pi)*tanh((2*pi*d)/y)

1个回答

  • 1.直接用solve函数

    T=input('');

    d=input('');

    f=subs('((9.8*T^2)/2*pi)*tanh((2*pi*d)/y)-y',{'T','d'},{T,d});

    a=solve(f,'y')

    》T=2,d=3

    结果

    a=-32.323847772664794935753715077212.

    2.Newton迭代法

    设定了迭代的最大次数100,可以自己改动的

    T=input(''); d=input('');

    syms xk x a i

    fx=input('Please input a f(x):');

    gx=x-fx/diff(fx)

    x0=input('Please input a initial number x0=');

    p =input('Please input a precision (即|Xk-Xk-1|/|Xk|