フィルターのクリア

Is there a way to pass a function handle as an argument for fsolve command?

1 回表示 (過去 30 日間)
Tarek Hajj Shehadi
Tarek Hajj Shehadi 2022 年 10 月 18 日
編集済み: Matt J 2022 年 10 月 18 日
I am trying to extract the fixed (equilibrium) point from a system of two ODEs. First, I constructed the function handle that holds both ODEs
F = @(t) [y(2); (R*omega^2/l)*cos(y(1) - omega*t) - (g/l)*sin(y(1))];
where R=0.5; omega = 0.25; l=1; and g=9.81;. As for omega, it is a function of theta and I managed to extract it as a vector by using ode45. I thought of using fsolve for achieving my main purpose of finding fixed points:
ye = fsolve(@F,[pi/4,pi/4]);
However, this returns an error that F is unrecognized function or variable. This leads me to think that fsolve does not accept function handles. Therefore, I hope there is a way to find fixed points either by using fsolve or via another way. Any help is appreciated.

回答 (1 件)

Matt J
Matt J 2022 年 10 月 18 日
編集済み: Matt J 2022 年 10 月 18 日
F is already a function handle, so the call should be something like,
F = @(y) [y(2); (R*omega^2/l)*cos(y(1) - omega*t) - (g/l)*sin(y(1))];
ye = fsolve(F,[pi/4,pi/4]);
However, it is pretty clear that for F(y)=0 that y(2)=0, so really you could have just solved for y(1) using,
f=@(y1) (R*omega^2/l)*cos(y(1) - omega*t) - (g/l)*sin(y1);
y1=fzero(f,pi/4);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by