필터 지우기
필터 지우기

not enough input arguments( not what you think)

조회 수: 1 (최근 30일)
Netanel Malihi
Netanel Malihi 2021년 11월 16일
댓글: Netanel Malihi 2021년 11월 16일
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 ?
Netanel Malihi
Netanel Malihi 2021년 11월 16일
thanks

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


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