Borrar filtros
Borrar filtros

not enough input arguments( not what you think)

1 visualización (últimos 30 días)
Netanel Malihi
Netanel Malihi el 16 de Nov. de 2021
Comentada: Netanel Malihi el 16 de Nov. de 2021
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

Respuestas (2)

the cyclist
the cyclist el 16 de Nov. de 2021
Editada: the cyclist el 16 de Nov. de 2021
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 comentarios
Netanel Malihi
Netanel Malihi el 16 de Nov. de 2021
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 el 16 de Nov. de 2021
thanks

Iniciar sesión para comentar.


Jan
Jan el 16 de Nov. de 2021
Editada: Jan el 16 de Nov. de 2021
"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.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by