フィルターのクリア

Iterative solution to approach desired value

3 ビュー (過去 30 日間)
M Teaxdriv
M Teaxdriv 2022 年 5 月 19 日
コメント済み: M Teaxdriv 2022 年 5 月 20 日
Hello,
I would like to find desired value Q = 7.76 using starting external solver in my Matlab script. Input for the external solver is value p. From several runs of the external solver I found the following values of p = pQ(:,1) and corresponding Q = pQ(:,2). How to find desired value 7.76? I found several examples of algorithms like Newton-Raphson but they use analytical equation, what I don't have here. Could you help to write such script?
Best regards
Michal
pQ = [
0.99471e+5 20.014;
0.99871e+5 4.89;
99795.887596 7.735;
99795.941823 7.733;
99795.964903 7.732;
99795.976825 7.731;
99796.01 7.73
]

採用された回答

Walter Roberson
Walter Roberson 2022 年 5 月 19 日
編集済み: Walter Roberson 2022 年 5 月 19 日
fzero() or fsolve().
If you need to be able to look at the complete source code then https://www.mathworks.com/matlabcentral/fileexchange/72478-bisection-method
Note that when you do not reply to my suggestions such as https://www.mathworks.com/matlabcentral/answers/1721605-iterative-solution-to-achieve-convergence#comment_2165925 then it is difficult for the volunteers to guess what you need different than what has already been suggested.
  8 件のコメント
Torsten
Torsten 2022 年 5 月 19 日
編集済み: Torsten 2022 年 5 月 19 日
I restricted the search interval to (90000:100000):
p0 = 99.925e+3 ; % some start value for p in [90000:100000] such that f(p) = 7.76
p0_trans = tan( (p0-95000)/5000 * pi/2);
p = fzero(@fun,p0_trans);
p_backtrans = 2/pi*atan(p)*5000 + 95000
function res = fun(p)
p_backtrans = 2/pi*atan(p)*5000 + 95000;
% Calculate Q as a function of p
save('p_value.mat',num2str(p_backtrans))
run external_solver
results = readtable('Results.txt')
Q = results.Q
res = Q - 7.76;
end
M Teaxdriv
M Teaxdriv 2022 年 5 月 20 日
Thanks a lot for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by