How do I fix this error? Not enough input arguments.

1 visualización (últimos 30 días)
James Bagnall
James Bagnall el 24 de Ag. de 2019
Comentada: Star Strider el 24 de Ag. de 2019
Im running this function:
function value = a_p(e)
%analysing power
a2 = [ ];
b2 = [ ];
%find value closest to randomly selected energy, e
[~,I] = min(abs(a2-e));
c2 = a2(I);
%find corresponding analysing power to that energy value
idx = find(a2 == c2);
bidx = b2(idx);
a_p = b2(idx);
value = a_p;
end
where a2 and b2 is just an array of data, I keep recieving the same error:
Not enough input arguments
Error in a_p (line 7)
[~,I] = min(abs(a2-e));

Respuesta aceptada

Star Strider
Star Strider el 24 de Ag. de 2019
Your ‘a_p’ function has no idea what ‘a2’ and ‘b2’ are because you have not shared those with them.
Try this:
function value = a_p(e,a2,b2)
%analysing power
%find value closest to randomly selected energy, e
[~,I] = min(abs(a2-e));
c2 = a2(I);
%find corresponding analysing power to that energy value
idx = find(a2 == c2);
bidx = b2(idx);
a_p = b2(idx);
value = a_p;
end
Change your calls to ‘a_p’ to include the extra arguments. Note that your find call requires that ‘a2’ exactly equals ‘c2’, and with integers that may work. However with floating-point operations that may not be true, even if they appear to be equal in the format you are viewing them.
  4 comentarios
James Bagnall
James Bagnall el 24 de Ag. de 2019
Yes it works now, e is assigned randomly via a different functions, thanks for the help
Star Strider
Star Strider el 24 de Ag. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by