フィルターのクリア

fsolve with another function

1 回表示 (過去 30 日間)
beginner
beginner 2016 年 3 月 12 日
コメント済み: Star Strider 2016 年 3 月 12 日
Hey,
I have a function which looks like:
function F = ex5(A_CL)
% Constants
theta = 86/180*pi;
delta_GL = 3.28*10^-10; %[m]
gamma_L = 0.0728; %[J/m^2]
N = Inf;
% equation to solve
F = gamma_L*(1+cos(theta))-vdW_layer(delta_GL, A_CL,N);
end
This function calls up another funcition vdW-layer(delta_GL, A_CL, N).
Now I want to solve the function/ find out the A_CL, having delta_GL and N as input variables and A_CL remains unknown.
I tried with this code:
fun5 = @(A_CL) ex5(A_CL);
A_CL_init = 10e-78; %initial guess
[A_CL, fval] = fsolve(fun5, A_CL_init);
where is my mistake??
thanks a lot!!!

採用された回答

Star Strider
Star Strider 2016 年 3 月 12 日
You have to edit your ‘ex5’ function to allow it to use extra input arguments:
function F = ex5(A_CL, delta_GL, N)
% Constants
theta = 86/180*pi;
% % delta_GL = 3.28*10^-10; %[m] % Now An Input Argument, So Delete Here
gamma_L = 0.0728; %[J/m^2]
% % N = Inf; % Now An Input Argument, So Delete Here
% equation to solve
F = gamma_L*(1+cos(theta))-vdW_layer(delta_GL, A_CL,N);
end
Then this changes to accommodate the new inputs to ‘ex5’:
delta_GL = . . .;
N = . . .;
fun5 = @(A_CL) ex5(A_CL, delta_GL, N);
A_CL_init = 10e-78; %initial guess
[A_CL, fval] = fsolve(fun5, A_CL_init);
Note: I did not run your code, so I’m labeling my changes as UNTESTED CODE, however it should work.
  3 件のコメント
beginner
beginner 2016 年 3 月 12 日
my mistake!! it works! thanks!
Star Strider
Star Strider 2016 年 3 月 12 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by