Not Enough Input Arguments

I've been trying to run the following function, but cannot get it to run without the above error. I have a script file that includes values for all of the input arguments listed. Can anyone spot an error that I'm missing?
function [ New_Phi ] = New_Phi_well( x,y,xw,yw,rw,Q,L,d,Qx0,Phi0 )
rsq=(x-xw)^2+(y-yw)^2;
rwsq=rw^2;
if rsq<rwsq
New_Phi=0;
else
New_Phi=Q/(2*pi)*(log(rsq/rwsq)/(log(L-d)-log(L+d)))-Qx0+Phi0;
end
end

1 个评论

It is simple.....you are not providing all the inputs the functions needs.

请先登录,再进行评论。

 采纳的回答

I just done this and it does work for me.
function [ New_Phi ] = New_Phi_well( x,y,xw,yw,rw,Q,L,d,Qx0,Phi0 )
x=10,y=2,xw=3,yw=4,rw=5,Q=3,L=5,d=6,Qx0=2,Phi0=1; % I've just used random values, try using 'input' (asking user input here)
rsq=(x-xw)^2+(y-yw)^2;
rwsq=rw^2;
if rsq<rwsq
New_Phi=0
else New_Phi=Q/(2*pi)*(log(rsq/rwsq)/(log(L-d)-log(L+d)))-Qx0+Phi0
end
I've got the answer like
New_Phi =
-1.0551 - 0.0722i
when I called 'New_Phi_well' in command window. Also try if the values you said are available and check the current folder option (for the availability of your program or input data called) too. Sometimes this throws errors for me.
Good day.

1 个评论

I was able to produce an answer this way too. I'm also trying to create a plot with varying x's and y's, so I believe there are errors elsewhere outside this function. Thanks for your help!

请先登录,再进行评论。

更多回答(1 个)

It is not enough that the script defines values with the same name as the parameters: you have to put the values in the calling sequence positionally.
So for example you cannot define values for x, y, xw, yw, rw, Q, L, d, Qx0, and Phi0, and then invoke
result = New_Phi_well;
You need to instead
result = New_Phi_well( x,y,xw,yw,rw,Q,L,d,Qx0,Phi0 );
providing each variable into its proper position.

2 个评论

Yes, I have that part in my script too. For some reason it still is giving me the "not enough in put arguments" error and specifies it is within the function itself.
We need to see your code and we need to see the exact error message.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by