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일

0 개 추천

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일
I get an error message, saying "Not enough input arguments." :/
beginner
beginner 2016년 3월 12일
my mistake!! it works! thanks!
Star Strider
Star Strider 2016년 3월 12일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 External Language Interfaces에 대해 자세히 알아보기

질문:

2016년 3월 12일

댓글:

2016년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by