How do I fix this error? Not enough input arguments.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Bagnall
am 24 Aug. 2019
Kommentiert: Star Strider
am 24 Aug. 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));
0 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Aug. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Computational Geometry finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!