how to get minimum positive solution?

1 回表示 (過去 30 日間)
huang
huang 2014 年 2 月 26 日
コメント済み: Star Strider 2014 年 2 月 26 日
1/K (sin(u)/u-cos(u))+(2-2cos(u)-usin(u))/L=0, K,L is constant, how to get the minimum positive solution of u?

採用された回答

Star Strider
Star Strider 2014 年 2 月 26 日
編集済み: Star Strider 2014 年 2 月 26 日
K = 11; L = 13;
scu = @(u) 1/K .* (sin(u)./u-cos(u))+(2-2.*cos(u)-u.*sin(u))/L;
uv = [];
for a = 0.01:10
us = fzero(scu, a);
uv = [uv; us];
end
mps = min(uv(uv > 0)) % Minimum Positive Solution
  2 件のコメント
huang
huang 2014 年 2 月 26 日
Thanks much, but how to keep K and L in the output?
Star Strider
Star Strider 2014 年 2 月 26 日
My pleasure!
The K and L variables are in the same MATLAB workspace that the function and code share. As long as K and L are defined first, before the equation, and the equation is defined before the call to fzero (as I did here), MATLAB will use them appropriately in the equation.
Note that fzero has some limitations. It requires that the equation provided to it is a function of one variable only. It also only returns real results, and those only close to the initial starting point. (This is the reason I used the for loop in both answers.)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by