'Not enough input arguments' error when using integral function

6 ビュー (過去 30 日間)
Gabriel Jenkins
Gabriel Jenkins 2017 年 3 月 28 日
編集済み: Stefan Rickli 2017 年 3 月 28 日
So i have this function
function y = aRIC_rea(W,x)
R=W(1); Rp=W(2); Cp=W(3); I=W(4); Ce=W(5);
A=1+((2*pi*x).*Rp*Cp).*((2*pi*x).*Rp*Cp);
a1= (2*pi*x).*(I.*A-Rp*Rp*Cp);
a2= A.*(1-(2*pi*x).*(2*pi*x)*I*Ce)+(2*pi*x).*(2*pi*x)*Rp*Rp*Cp*Ce;
a3= R.*A+Rp;
num= a1.*a2-(2*pi*x).*a3.*a3*Ce;
a4= (2*pi*x).*Ce.*a3;
denom= a2.*a2+a4.*a4;
y= num./denom;
end
I try to integrate in a separate script
W1 = [0.8329 5.9045 0.0178 0.0032 0.0011]
X1 = reshape(X,1,24)
funRea = @(W1,X1)aRIC_rea(W1,X1)
q = integral(funRea,5,Xres)
I get this error
funRea =
@(W1,X1)aRIC_rea(W1,X1)
Not enough input arguments.
Error in static0analysisaric>@(W1,X1)aRIC_rea(W1,X1)
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 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in static0analysisaric (line 55)
q = integral(funRea,5,Xres)

回答 (1 件)

Stefan Rickli
Stefan Rickli 2017 年 3 月 28 日
編集済み: Stefan Rickli 2017 年 3 月 28 日
Your code lacks the definition of X and Xres to run on my machine but I'll still give it a try.
I assume that the line
q = integral(funRea,5,Xres)
means that you want 'funRea' to be evaluated from 5 to some scalar 'Xres'.
I also deduct from your code that you want 'funRea' to be evaluated from x = 5 to Xres.
In order to achieve that you need a basic structure like
W = [1.1 2.2 3.3];
f_handle = @(x) my_function(x,W);
integral(f_handle,5,10)
function y = my_function (x1,x2)
y = x1.^2 + x2(1);
end
Notice that 'integral' expects a function handle with only one input, here it's 'x'. The second input of 'my_function' gets fed directly during the declaration of the function handle 'f_handle = @(x) my_function(x,W)'.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by