MATLAB: How do i link the menu bar function to the for loop. [Error indicates Not Enough Input argument]

for loopsfunctionsloopsmenu functionmodular script

function [Agelessthan25,Agebetween25to50,Ageabove50]= Agecategory(AgeofCasualty)
Agelessthan25=0;
Agebetween25to50=0;
Ageabove50=0;
for x=(1:length(AgeofCasualty));
curage = AgeofCasualty(x);
if curage < 25
Agelessthan25= Agelessthan25 + 1;
elseif curage >= 25 & curage < 50;
Agebetween25to50 =Agebetween25to50 +1;
else curage >= 50;
Ageabove50 = Ageabove50 +1;
end
end
fprintf('Agelessthan25 is %d\n', Agelessthan25)
fprintf('Agebetween25to50 is %d\n', Agebetween25to50)
fprintf('Ageabove50 is %d.0\n', Ageabove50)
end

Best Answer

Kenneth - please show the callback which includes the code that calls the Agecategory function. Given the error message and the signature of this function, I suspect that you are not passing the AgeofCasualty input parameter into this function. Since the signature is
function [Agelessthan25,Agebetween25to50,Ageabove50]= Agecategory(AgeofCasualty)
then you must call it like
[Agelessthan25,Agebetween25to50,Ageabove50]= Agecategory(42);
where 42 is passed as the input parameter into this function.