Not enough Input arguments in integral function

33 Ansichten (letzte 30 Tage)
Alix DUMAS
Alix DUMAS am 15 Okt. 2021
Kommentiert: Alix DUMAS am 15 Okt. 2021
Good afternoon,
I am trying to compute the exact Wagner function on MATLAB with the following equation : , where c(k) is the Theodorsen function. I already created a function computing c(k), but I am having trouble computing the integral. I have defined k = 0.1 and s = linspace(0,100,100).
For now I have tried two options with the integral(fun, xmin, xmax) function of MATLAB :
1) Create a function in another matlab script and then write W = (2./pi).*integral(fun_W,0, Inf). The result was an error saying :
"Not enough input arguments.
Error in W_integrande (line 2)
f = F_k(k).*sin(k.*s)./k;
Error in HMWK3_DUMAS (line 14)
W = (2./pi).*integral(W_integrande,0, Inf)"
2) On another forum I saw people using
"fun_W = @(k,s) real(c_k(k)).*sin(k.*s)./k;
W = (2./pi).*integral(fun_W,0, Inf)"
So I tried it and this time the error is
"Not enough input arguments.
Error in HMWK3_DUMAS>@(k,s)real(c_k(k)).*sin(k.*s)./k (line 13)
fun_W = @(k,s) real(c_k(k)).*sin(k.*s)./k;
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 83)
[q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in HMWK3_DUMAS (line 14)
W = (2./pi).*integral(fun_W,0, Inf);"
I don't understand why I am getting the error "not enough input arguments", could someone help me with this ?
Thank you in advance !
  2 Kommentare
David Hill
David Hill am 15 Okt. 2021
It would be helpful if you provided your function for c(k).
Alix DUMAS
Alix DUMAS am 15 Okt. 2021
Sure ! My function for c(k) is :
function[c] = c_k(k)
c = besselh(1,2,k)./(besselh(1,2,k)+j.*besselh(0,2,k));
end

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

David Hill
David Hill am 15 Okt. 2021
s=0:100;
for t=1:numel(s)
fun_W=@(k)real(c_k(k))./k.*sin(k*s(t));
W(t)=2/pi*integral(fun_W,0,Inf);
end
function c= c_k(k)
c = besselh(1,2,k)./(besselh(1,2,k)+1j.*besselh(0,2,k));%need 1j
end

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by