not enough input arguments( not what you think)

1 次查看(过去 30 天)
the function gets only one argument but it says not enough arguments ,
also its says x=x0 in line 6 but this specific data is not in line 6
what could be the problem?
function X_coordinate = beam(x0)
epsilon = 1e-4;
flag = 0;
counter = 0;
q0 = 0.5
L = 1000
I = 351*10^6
VIn = -0.5972
E = 100
x = x0;
while flag == 0
%Check for infinite loop
counter = counter + 1
if counter > 10000;
error('Too many iterations');
end
v = -(q0*L)/(3*pi^4*E*I)*(48*L^3*cos((pi*x)/(2*L))-48*L^3+3*pi^3*L*x^2-pi^3*x^3)
v_d = -(q0*L)/(3*pi^4*E*I)*(-48*L^3*(pi/(2*L))*sin((pi*x)/(2*L))+6*pi^3*L*x-3*pi^3*x^2)
x = x-v/v_d %solution
if abs(v/v_d) < epsilon || abs(v) < epsilon
flag = 1;
end
end
X_coordinate = x;
if X_coordinate <=0
error('No solution found,Please enter valid value')
else
X_coordinate = x
end

回答(2 个)

the cyclist
the cyclist 2021-11-16
编辑:the cyclist 2021-11-16
How are you calling this function?
I put your function in a file named beam.m, then called it from the Command Window using
beam(1)
and the code ran just fine.
If I try to call it as
beam() % call without required input
then I get the error message:
Not enough input arguments.
Error in beam (line 11)
x = x0;
  2 个评论
Netanel Malihi
Netanel Malihi 2021-11-16
i call it beam(500) and get not enough input arguments and also the i get the same error x=x0 but in line 6
how could it be ?

请先登录,再进行评论。


Jan
Jan 2021-11-16
编辑:Jan 2021-11-16
"its says x=x0 in line 6 but this specific data is not in line 6"
This means, that you do not call the function you think you are calling. Maybe you did not save the file before calling it or you have multiple files with the same name. Check this by:
which beam -all
You can set a breakpoint in the code you think you are calling. Then you will see, if it is reached at all.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by