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.
  1 件のコメント
Netanel Malihi
Netanel Malihi 2021 年 11 月 16 日
thank you i found the problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by